home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / os2dbutl.zip / LUDOSPY.C < prev    next >
C/C++ Source or Header  |  1993-03-09  |  122KB  |  3,036 lines

  1. /*............................................................................
  2. .                                                                            .
  3. .                                                                            .
  4. .                                                                            .
  5. .               --- Series III Life and Health Presents ---                  .
  6. .                                                                            .
  7. .                                                                            .
  8. .                                                                            .
  9. .                                                                            .
  10. .   Program ID......: LUDOSNAP.C                                             .
  11. .                                                                            .
  12. .   Program Title...:                                                        .
  13. .                                                                            .
  14. .   Version Number..: 1.00                                                   .
  15. .                                                                            .
  16. .   Operating System: OS/2                                                   .
  17. .                                                                            .
  18. .   Description.....:                                                        .
  19. .                                                                            .
  20. .                                                                            .
  21. .                                                                            .
  22. .   Parameters:                                                              .
  23. .                                                                            .
  24. .          Type           Name                 Description                   .
  25. .       ------------   --------------    ----------------------------        .
  26. .           N/A                                                              .
  27. .                                                                            .
  28. .                                                                            .
  29. .   Return Values:                                                           .
  30. .                                                                            .
  31. .        Type         Value      #define                Description          .
  32. .       --------      -----    ----------------     -----------------------  .
  33. .           N/A                                                              .
  34. .                                                                            .
  35. .                                                                            .
  36. .   Application Function Calls (Internal):                                   .
  37. .                                                                            .
  38. .            Function Name                    Description                    .
  39. .       ------------------------     --------------------------------        .
  40. .                                                                            .
  41. .                                                                            .
  42. .   Application Function Calls (External):                                   .
  43. .                                                                            .
  44. .            Function Name                    Description                    .
  45. .       ------------------------     --------------------------------        .
  46. .                N/A                                                         .
  47. .                                                                            .
  48. .   Special Processing:                                                      .
  49. .                                                                            .
  50. .                                                                            .
  51. .                                                                            .
  52. .   Internal Tables:                                                         .
  53. .                                                                            .
  54. .            Table Name                       Description                    .
  55. .       --------------------------   --------------------------------        .
  56. .            N/A                                                             .
  57. .                                                                            .
  58. .                                                                            .
  59. .   Application Specific Hungarian Prefixes:                                 .
  60. .                                                                            .
  61. .       Prefix              Description                                      .
  62. .       ------       --------------------------------------------            .
  63. .        N/A                                                                 .
  64. .                                                                            .
  65. .                                                                            .
  66. .   Member of Object Library:  N/A                                           .
  67. .                                                                            .
  68. .   Member of Dynamic Link Library:  N/A                                     .
  69. .                                                                            .
  70. .                                                                            .
  71. .                                                                            .
  72. ..............................................................................
  73. .                                                                            .
  74. .                       M A I N T E N A N C E    L O G                       .
  75. .                                                                            .
  76. .                                                                            .
  77. .   SI Number      Date      PGMR          Description                       .
  78. .   ---------    --------    ----    ------------------------------          .
  79. .                                                                            .
  80. .                                                                            .
  81. ............................................................................*/
  82.  
  83. /*....................................................................
  84. :                                                                    :
  85. :   Defines                                                          :
  86. :                                                                    :
  87. :...................................................................*/
  88.  
  89. #define INCL_BASE
  90. #define EXTERN
  91. #define TRUE 1
  92. #define FALSE 0
  93. #define SLEEP_TIME 950L
  94. #define STACK_SIZE 1024
  95. #define ARGS NULL
  96. #define MAX_USERS 101
  97. #define DELAY 1000L
  98.  
  99. #define BLACK 0
  100. #define BLUE 1
  101. #define GREEN 2
  102. #define CYAN 3
  103. #define RED 4
  104. #define MAGENTA 5
  105. #define BROWN 6
  106. #define WHITE 7
  107. #define GREY 8
  108. #define LT_BLUE 9
  109. #define LT_GREEN 10
  110. #define LT_CYAN 11
  111. #define LT_RED 12
  112. #define LT_MAGENTA 13
  113. #define YELLOW 14
  114. #define BRI_WHITE 15
  115. #define LT_RED_BLINK 28
  116.  
  117. #define WM_REDRAW          WM_USER  +251
  118. #define WM_FINISH          WM_USER  +252
  119.  
  120. /*....................................................................
  121. :                                                                    :
  122. :   OS/2 include headers                                             :
  123. :                                                                    :
  124. :...................................................................*/
  125.  
  126. #include "LUDOSPY.H"
  127.  
  128. /*....................................................................
  129. :                                                                    :
  130. :   SQL include headers                                              :
  131. :                                                                    :
  132. :...................................................................*/
  133.  
  134. #include <sql.h>
  135. #include <sqlca.h>
  136. #include <sqlenv.h>
  137. #include <sqlutil.h>
  138.  
  139. /*....................................................................
  140. :                                                                    :
  141. :   Global variables                                                 :
  142. :                                                                    :
  143. :...................................................................*/
  144.  
  145. char           sz_log[15];
  146. char           sz_mode[9];
  147. char           sz_stats[256];
  148. char           sz_code[20];
  149. char           sz_title[80];
  150. char           sz_dbase[10];
  151. char           sz_buff[81];
  152. char           sz_conn[5];
  153. char           sz_conns[10];
  154. char           sz_nodename[9]; 
  155. char           sz_partner_lu[9];
  156. char           sz_local_lu[9]; 
  157. char           sz_comment[31];
  158. char           sz_db_entry[9];
  159. char           sz_time_out[30];
  160. char           sz_date_time[26];
  161. char           sz_user_buff[256];
  162. char           sz_alias[25][9];
  163. char           sz_node[25][9];
  164. char           sz_un_alias[25][9];
  165. char           sz_un_nodename[25][9];
  166. char           sz_trans_con[9]; 
  167. char           sz_req_con[9];
  168. char           sz_req_cur[9];
  169. char           sz_rds_name[9];
  170. char           sz_new_title[22];
  171. char           sz_scan[10];
  172.  
  173. BYTE           stack[STACK_SIZE];
  174. BYTE           wch_stack[STACK_SIZE];
  175.  
  176. unsigned short us_db_count;
  177. unsigned short us_count_dir;
  178. unsigned short us_count_node;
  179. unsigned short us_row;
  180. unsigned short us_col;
  181. unsigned short us_hand_dir;
  182. unsigned short us_hand_node;
  183. unsigned short us_scan;
  184.  
  185. HWND hWndDbDlg;
  186. HWND hWndReFresh;
  187.  
  188. /*....................................................................
  189. :                                                                    :
  190. :   Structures                                                       :
  191. :                                                                    :
  192. :...................................................................*/
  193.  
  194. struct sqlca sqlca;
  195.  
  196. /* System Status data structure */
  197.  
  198. struct dbstat
  199. {
  200.   unsigned long  current_time;
  201.            long  time_zone_disp1;
  202.   unsigned char  product_name[SQL_PRODNAME_SZ];
  203.   unsigned char  component_id[SQL_COMPID_SZ];
  204.   unsigned char  reserved1;                      /* Reserved byte  */
  205.   unsigned char  release_lvl[SQL_RLSLVL_SZ];
  206.   unsigned char  corr_serv_lvl[SQL_CORRLVL_SZ];
  207.   unsigned long  backup_time;             /* Last backup time           */
  208.            long  time_zone_disp2;         /* Time zone of backup time   */
  209.   unsigned short connects;                /* Number of current users    */
  210.   unsigned char  db_alias[SQL_DBSTAT_ALIAS_SZ];  /* Alias name          */
  211.   unsigned char  db_name[SQL_DBSTAT_DBNAME_SZ];  /* Database name       */
  212.   unsigned char  location;                /* Local / Remote Database    */
  213.   unsigned char  reserved2;               /* Reserved byte              */
  214.   unsigned char  drive[SQL_DRIVE_SZ];     /* Drive containing database  */
  215.   unsigned char  node[SQL_NNAME_SZ];      /* Node containing database   */
  216.   unsigned char  db_type[SQL_DBTYP_SZ];   /* "OS2 DBM"                  */
  217.   struct userstat
  218.      {
  219.      unsigned long  con_trans;            /* Transactions since connect */
  220.      unsigned long  con_reqs;             /* Requests since connect     */
  221.      unsigned long  cur_reqs;             /* Requests current transact  */
  222.      unsigned long  connect_time;         /* Time since connect         */
  223.      unsigned long  trans_time;           /* Time since current transact*/
  224.      unsigned char  authid[SQL_USERID_SZ];/* User's Id                  */
  225.      unsigned char  node[SQL_NNAME_SZ];   /* Nodename of connected user */
  226.      unsigned short authority_lvl;        /* User's authority level     */
  227.      unsigned char  trans_state;          /* Transaction state          */
  228.      unsigned char  lock_state;           /* Transaction lock state     */
  229.      } ustat[MAX_USERS];
  230.   } *pdbstat;
  231.  
  232. struct dbstat basestat;
  233.  
  234. time_t         bintime;
  235. time_t         con_time;
  236.  
  237. struct tm *curtime;
  238. struct tm *out_time;
  239.  
  240. struct sqlca sqlca;
  241. struct sqledinfo *st_info;
  242. struct sqleninfo *st_node;
  243. struct sql_authorizations st_auth, *p_auth = &st_auth;
  244.  
  245. /*....................................................................
  246. :                                                                    :
  247. :   Bit structures                                                   :
  248. :                                                                    :
  249. :...................................................................*/
  250.  
  251.   struct logical
  252.      {
  253.      unsigned cat    : 1;  /*TRUE catolog database                  */
  254.      unsigned node   : 1;  /*TRUE catolog node                      */
  255.      unsigned noconn : 1;  /*TRUE there is no connections           */
  256.      unsigned append : 1;  /*TRUE append log file                   */
  257.      unsigned over   : 1;  /*TRUE overwrite log file                */
  258.      unsigned none   : 1;  /*TRUE do not use log file               */
  259.      unsigned tend   : 1;  /*TRUE to end the refresh thread         */
  260.      unsigned draw   : 1;  /*TRUE if screen is already drawing      */
  261.      unsigned time   : 1;  /*TRUE if refresh time has expired       */
  262.      }
  263.      bit_flag;
  264.  
  265. /*....................................................................
  266. :                                                                    :
  267. :   File Structures                                                  :
  268. :                                                                    :
  269. :...................................................................*/
  270.  
  271. FILE *spyfile;
  272.  
  273. /*....................................................................
  274. :                                                                    :
  275. :   function prototypes                                              :
  276. :                                                                    :
  277. :...................................................................*/
  278.  
  279. void dir_scan(void);
  280. void db_crash(void);
  281. void get_time(void);
  282. void node_scan(void);
  283. void sort_users(void);
  284. void write_db_stats(void);
  285. void write_user_stats(void);
  286. void refresh_thread(void);
  287. void wch_thread(void);
  288.  
  289. /***************************************************************************/
  290. /*                                                                         */
  291. /* Presentation Manager Program Main Body                                  */
  292. /*                                                                         */
  293. /* The following routine is the Presentation Manager program Main Body.    */
  294. /* The Main Body of a PM program is concerned with associating the         */
  295. /* application with the Presentation Manager system, creating its          */
  296. /* message queue, registering and displaying its main window, servicing    */
  297. /* its message queue during the time that the application is active,       */
  298. /* and disassociating the application from PM when the user is finished    */
  299. /* with the application. The remaining parts of this source module that    */
  300. /* are concerned with the Presentation Manager are the application's       */
  301. /* window procedures (main window procedure, child window procedures,      */
  302. /* and dialog window procedures) that process the messages associated      */
  303. /* with the application's various windows.                                 */
  304. /*                                                                         */
  305. /***************************************************************************/
  306.  
  307. SHORT cdecl main(argc, argv)
  308. int argc;
  309. char *argv[];
  310. {
  311.  QMSG qmsg;  /* MSG structure to store your messages                       */
  312.  PID  pid;   /* Process identifier for adding name to switch list          */
  313.  TID  tid;   /* Thread identifier                                          */
  314.  static CHAR szTitle[8];
  315.  
  316.  /* The WinInitialize routine initializes the Presentation Manager         */
  317.  /* facilities for use by this application and returns a handle to the     */
  318.  /* anchor block assigned to the application by PM.                        */
  319.  
  320.  bit_flag.append = FALSE;
  321.  bit_flag.over = FALSE;
  322.  bit_flag.none = TRUE;
  323.  bit_flag.draw = FALSE;
  324.  us_scan = 30;
  325.  
  326.  SQLGSTAR();
  327.  
  328.  if((hAB = WinInitialize(0)) == 0)
  329.     return(FALSE);
  330.   
  331.  /* The WinCreateMsgQueue call creates a message queue for this application*/
  332.  
  333.  if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
  334.     return(FALSE);
  335.  
  336.  /* The following function registers the classes of all application windows*/
  337.  if(!cwRegisterClass())
  338.     return(FALSE);
  339.  
  340.  /**************************************************************************/
  341.  /* IPF Initialization Structure                                           */
  342.  /**************************************************************************/
  343.  
  344.  hiLUDOSPYHelp.cb = sizeof(HELPINIT);  /* size of init structure      */
  345.  hiLUDOSPYHelp.ulReturnCode = 0;
  346.  hiLUDOSPYHelp.pszTutorialName = 0; /* no tutorial                         */
  347.  hiLUDOSPYHelp.phtHelpTable = (PVOID)(0xffff0000 | ID_LUDOSPY);
  348.  hiLUDOSPYHelp.hmodAccelActionBarModule = 0;
  349.  hiLUDOSPYHelp.idAccelTable = 0;
  350.  hiLUDOSPYHelp.idActionBar = 0;
  351.  hiLUDOSPYHelp.pszHelpWindowTitle = "LUDOSPY";
  352.  hiLUDOSPYHelp.hmodHelpTableModule = 0;
  353.  hiLUDOSPYHelp.usShowPanelId = 0;
  354.  hiLUDOSPYHelp.pszHelpLibraryName = "LUDOSPY.HLP";
  355.  
  356.  /**************************************************************************/
  357.  /* Create Instance of IPF                                                 */
  358.  /**************************************************************************/
  359.  
  360.  hWndLUDOSPYHelp = WinCreateHelpInstance(hAB, &hiLUDOSPYHelp);
  361.  if(!hWndLUDOSPYHelp || hiLUDOSPYHelp.ulReturnCode)
  362.    {
  363.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  364.                   (PSZ)"No help is available.",
  365.                   (PSZ) szAppName,
  366.                   1,
  367.                   MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  368.     WinDestroyHelpInstance(hWndLUDOSPYHelp);
  369.    }
  370.  
  371.  /* The CreateWindow function creates a frame window for this application's*/
  372.  /* top window, and set the window's size and location as appropriate.     */
  373.  
  374.  WinLoadString(hAB, 0, IDS_TITLE, 8, szTitle);
  375.  hWndFrame = cwCreateWindow((HWND)HWND_DESKTOP,
  376.           FCF_TITLEBAR     |
  377.           FCF_SYSMENU      |
  378.           FCF_MINBUTTON    |
  379.           FCF_MAXBUTTON    |
  380.           FCF_SIZEBORDER   |
  381.           FCF_MENU         |
  382.           FCF_ACCELTABLE   |
  383.           FCF_SHELLPOSITION,
  384.           szAppName,
  385.           szTitle,
  386.           ID_LUDOSPY,
  387.           0, 0,
  388.           0, 0,
  389.           &hWndClient,
  390.           0L,SWP_MAXIMIZE | SWP_SHOW);
  391.  
  392.  if(hWndFrame == 0)
  393.     return(FALSE);
  394.  
  395.  /**************************************************************************/
  396.  /* Associate Instance of IPF                                              */
  397.  /**************************************************************************/
  398.  if(hWndLUDOSPYHelp)
  399.    WinAssociateHelpInstance(hWndLUDOSPYHelp, hWndFrame);
  400.  /* The following inline routine fills out the application's switch control*/
  401.  /* structure with the appropriate information to add the application's    */
  402.  /* name to the OS/2 Task Manager List, a list of the jobs currently       */
  403.  /* running on the computer.                                               */
  404.  
  405.  WinQueryWindowProcess(hWndFrame, &pid, &tid);
  406.  Swctl.hwnd = hWndFrame;                         /* Frame window handle    */
  407.  Swctl.idProcess = pid;                          /* Process identifier     */
  408.  Swctl.uchVisibility = SWL_VISIBLE;              /* visibility             */
  409.  Swctl.fbJump = SWL_JUMPABLE;                    /* Jump indicator         */
  410.  strcpy(Swctl.szSwtitle, szTitle);               /* Frame window title     */
  411.  hSwitch = WinAddSwitchEntry(&Swctl);
  412.    
  413.  /* The following is the message loop for the application.                 */
  414.  
  415.  while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
  416.        WinDispatchMsg(hAB,(PQMSG)&qmsg);
  417.  
  418.  /* Perform clean up before exiting application.                           */
  419.  /**************************************************************************/
  420.  /* Destroy Instance of IPF                                                */
  421.  /**************************************************************************/
  422.  if(hWndLUDOSPYHelp)
  423.     WinDestroyHelpInstance(hWndLUDOSPYHelp);
  424.  /* The following routine destroys the application's frame window (which   */
  425.  /* also destroys its child windows), destroys its message queue, and      */
  426.  /* disassociates the application from the Presentation Manager system.    */
  427.  
  428.  WinDestroyWindow(hWndFrame); /* Destroy the frame window                  */
  429.  WinDestroyMsgQueue(hMQ);     /* Destroy this application's message queue  */
  430.  WinTerminate(hAB);           /* Terminate this application's use of the   */
  431.                               /* Presentation Manager resources            */
  432. } /* end of main */
  433.  
  434.  
  435. /* The following Dialog box calls are generated for the dialog boxes that  */
  436. /* have been selected as "Unlinked" dialog boxes.  To use these calls,     */
  437. /* simply copy them to the appropriate location in the application.        */
  438.  
  439. #if 0
  440.  
  441.    WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CATMsgProc, 
  442.              0, IDLG_CAT, (PBYTE)hWnd);
  443.  
  444.    WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)NODEMsgProc, 
  445.              0, IDLG_NODE, (PBYTE)hWnd);
  446.  
  447.    WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)NO_CONMsgProc, 
  448.              0, IDLG_NO_CON, (PBYTE)hWnd);
  449.  
  450.    WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)STATUSMsgProc, 
  451.              0, IDLG_STATUS, (PBYTE)hWnd);
  452.  
  453. #endif
  454.  
  455. /***************************************************************************/
  456. /*                                                                         */   
  457. /* Main Window Procedure                                                   */
  458. /*                                                                         */
  459. /* This procedure provides service routines for the general PM events      */
  460. /* (messages) that PM sends to the window, as well as the user             */
  461. /* initiated events (messages) that are generated when the user selects    */
  462. /* the action bar and pulldown menu controls or the corresponding          */
  463. /* keyboard accelerators.                                                  */
  464. /*                                                                         */
  465. /* The SWITCH statement shown below distributes the window messages to     */
  466. /* the respective message service routines, which are set apart by the     */
  467. /* CASE statements. The window procedures must provide an appropriate      */
  468. /* service routine for its end user initiated messages, as well as the     */
  469. /* general PM messages (like the WM_CLOSE message). If a message is        */
  470. /* sent to this procedure for which there is no programmed CASE clause     */
  471. /* (i.e., no service routine), the message is defaulted to the             */
  472. /* WinDefWindowProc function, where it is disposed of by PM.               */
  473. /*                                                                         */
  474. /***************************************************************************/
  475.  
  476. MRESULT EXPENTRY WndProc(hWnd, message, mp1, mp2)
  477. HWND hWnd;
  478. USHORT message;
  479. MPARAM mp1;
  480. MPARAM mp2;
  481. {                        /* Beginning of message processor                 */
  482.    HPS hPS;              /* Handle for the Presentation Space              */
  483.    RECTL rClient;        /* Handle to rectangle formed by client area      */
  484.    USHORT rc;            /* common return code value                       */
  485.  
  486.    switch(message)
  487.      {
  488.       case WM_COMMAND:
  489.         /* The PM messages for action bar and pulldown menu items are      */
  490.         /* processed in this routine.                                      */
  491.   
  492.            switch(SHORT1FROMMP(mp1))
  493.             {
  494.              case IDM_F_EXIT:
  495.                   /* Place User Code to respond to the                     */
  496.                   /* Menu Item Named "E~xit" here.                         */
  497.                   WinPostQueueMsg(hMQ, WM_QUIT, NULL, NULL); 
  498.                   break;
  499.  
  500.              case IDM_P_SCANINTERVAL:
  501.                   /* This makes a call to the dialog box named             */
  502.                   /* "INTERVAL" rc will receive the return code            */
  503.                   /* sent when the dialog box is closed                    */
  504.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)INTERVALMsgProc,
  505.                                  0, IDLG_INTERVAL, (PBYTE)hWnd);
  506.                   break;
  507.  
  508.              case IDM_P_FILEOPTIONS:
  509.                   /* This makes a call to the dialog box named             */
  510.                   /* "FILES" rc will receive the return code               */
  511.                   /* sent when the dialog box is closed                    */
  512.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)FILESMsgProc,
  513.                                  0, IDLG_FILES, (PBYTE)hWnd);
  514.                   break;
  515.  
  516.              case IDM_P_DATABASE:
  517.                   if (!WinIsWindow(hAB, hWndDATABASE))
  518.                     {
  519.                       hWnd = WinLoadDlg(HWND_DESKTOP, hWnd,
  520.                          (PFNWP)DATABASEMsgProc, 0, IDLG_DATABASE, (PBYTE)hWnd);
  521.                     }
  522.                    else
  523.                     WinSetFocus(HWND_DESKTOP, hWndDATABASE);
  524.                   break;
  525.  
  526.              case IDM_P_CATOLOGDATABASE:
  527.                   /* This makes a call to the dialog box named             */
  528.                   /* "CAT" rc will receive the return code                 */
  529.                   /* sent when the dialog box is closed                    */
  530.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CATMsgProc,
  531.                                  0, IDLG_CAT, (PBYTE)hWnd);
  532.                   break;
  533.  
  534.              case IDM_P_UNCATOLOGDATABASE:
  535.                   /* This makes a call to the dialog box named             */
  536.                   /* "UN_CAT" rc will receive the return code              */
  537.                   /* sent when the dialog box is closed                    */
  538.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)UN_CATMsgProc,
  539.                                  0, IDLG_UN_CAT, (PBYTE)hWnd);
  540.                   break;
  541.  
  542.              case IDM_P_CATOLOGNODE:
  543.                   /* This makes a call to the dialog box named             */
  544.                   /* "NODE" rc will receive the return code                */
  545.                   /* sent when the dialog box is closed                    */
  546.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)NODEMsgProc,
  547.                                  0, IDLG_NODE, (PBYTE)hWnd);
  548.                   break;
  549.  
  550.              case IDM_P_UNCATOLOGNODE:
  551.                   /* This makes a call to the dialog box named             */
  552.                   /* "UN_NODE" rc will receive the return code             */
  553.                   /* sent when the dialog box is closed                    */
  554.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)UN_NODEMsgProc,
  555.                                  0, IDLG_UN_NODE, (PBYTE)hWnd);
  556.                   break;
  557.  
  558.  
  559.             case IDM_H_HELPFORHELP:
  560.                  if(hWndLUDOSPYHelp)
  561.                     WinSendMsg(hWndLUDOSPYHelp, HM_DISPLAY_HELP, 0L, 0L);
  562.                  break;
  563.  
  564.  
  565.              default:
  566.                   break; /* End of default case for switch(mp1) */
  567.             }
  568.            break; /* End of WM_COMMAND */
  569.  
  570.  
  571.       case HM_QUERY_KEYS_HELP:
  572.            /* If the user requests Keys Help from the help pulldown,       */
  573.            /* IPF sends the HM_QUERY_KEYS_HELP message to the application, */
  574.            /* which should return the panel id of the Keys Help panel      */
  575.            return((MRESULT)999);
  576.            break;
  577.  
  578.       case HM_ERROR:
  579.            /* If an IPF error occurs, an HM_ERROR message will be sent to  */
  580.            /* the application.                                             */
  581.            if(hWndLUDOSPYHelp && ((ULONG)mp1) == HMERR_NO_MEMORY)
  582.              {
  583.               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  584.                             (PSZ) "Help Terminated Due to Error",
  585.                             (PSZ) "Help Error",
  586.                             1,
  587.                             MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  588.               WinDestroyHelpInstance(hWndLUDOSPYHelp);
  589.              }
  590.             else
  591.              {
  592.               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  593.                             (PSZ) "Help Error Occurred",
  594.                             (PSZ) "Help Error",
  595.                             1,
  596.                             MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  597.              }
  598.            break;
  599.  
  600.       case WM_CREATE:
  601.            /* The WM_CREATE message is sent to a window when an application*/
  602.            /* requests that the window be created.  The window procedure   */
  603.            /* for the new window receives this message after the window is */
  604.            /* created, but before the window becomes visible.              */
  605.            /*                                                              */
  606.            cwSetInitDlgStatus(hWnd);
  607.            break; /* End of WM_CREATE */
  608.  
  609.       case WM_MOUSEMOVE:
  610.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  611.            break;
  612.  
  613.       case WM_SIZE:     /* code for sizing client area                     */
  614.            break;       /* End of WM_SIZE                                  */
  615.     
  616.       case WM_PAINT:    /* code for the window's client area               */
  617.            /* Obtain a handle to a cache presentation space                */
  618.            hPS = WinBeginPaint(hWnd, 0, 0);
  619.  
  620.            /* Determine the size of the client area                        */
  621.            WinQueryWindowRect(hWnd, &rClient);
  622.  
  623.            /* Fill the background with the default background color        */
  624.            WinFillRect(hPS, &rClient, CLR_CYAN);
  625.  
  626.            /* return presentation space to state before WinBeginPaint      */
  627.            WinEndPaint(hPS);
  628.            break; /* End of WM_PAINT */
  629.  
  630.  
  631.       case WM_CLOSE:  /* close the window                                  */
  632.            if(hWnd != hWndClient)
  633.              break;
  634.            cwFreeDlgMemory(hWnd);
  635.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  636.            break; /* End of WM_CLOSE */
  637.      
  638.       default:
  639.            /* For any message for which you don't specifically provide a   */
  640.            /* service routine, you should return the message to PM using   */
  641.            /* the WinDefWindowProc function.                               */
  642.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  643.            break;  /* End of default */
  644.      } 
  645.    return(0L);
  646. } /* End of WndProc */
  647.  
  648. /***************************************************************************/
  649. /*                                                                         */
  650. /* Dialog Window Procedure                                                 */
  651. /*                                                                         */
  652. /* This procedure is associated with the dialog box that is included in    */
  653. /* the function name of the procedure. It provides the service routines    */
  654. /* for the events (messages) that occur because the end user operates      */
  655. /* one of the dialog box's buttons, entry fields, or controls.             */
  656. /*                                                                         */
  657. /* The SWITCH statement in the function distributes the dialog box         */
  658. /* messages to the respective service routines, which are set apart by     */
  659. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  660. /* procedures must provide an appropriate service routine for their end    */
  661. /* user initiated messages as well as for the general PM messages (like    */
  662. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  663. /* which there is no programmed CASE condition (no service routine),       */
  664. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  665. /* disposed of by PM.                                                      */
  666. /*                                                                         */
  667. /***************************************************************************/
  668.  
  669. MRESULT EXPENTRY INTERVALMsgProc(hWndDlg, message, mp1, mp2)
  670. HWND hWndDlg;
  671. USHORT message;
  672. MPARAM mp1;
  673. MPARAM mp2;
  674.  static SHORT sfValidate = TRUE;
  675.  INT    i;
  676.  static HWND  hWndParent;
  677.           
  678.  switch(message)
  679.    {
  680.     case WM_INITDLG:
  681.          hWndParent = (HWND)mp2;
  682.          cwCenter(hWndDlg, (HWND)hWndParent);
  683.          WinSendDlgItemMsg(hWndDlg, 257, EM_SETTEXTLIMIT, (MPARAM)4, NULL);
  684.          break; /* End of WM_INITDLG */
  685.    
  686.     case WM_CONTROL:
  687.          switch(SHORT1FROMMP(mp1))
  688.            {
  689.             case 257: /* Entry field                                       */
  690.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  691.                    { 
  692.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  693.                          break;
  694.  
  695.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  696.                          break;
  697.  
  698.                     default: /* Default other messages                     */
  699.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  700.                          break;
  701.                    }
  702.                  break;
  703.  
  704.            }
  705.          break; /* End of WM_CONTROL */
  706.    
  707.     case WM_COMMAND:
  708.          switch(SHORT1FROMMP(mp1))
  709.            {
  710.             case DID_OK: /* Button text: "Ok"                              */
  711.                  WinQueryDlgItemText(hWndDlg, 257,
  712.                                      sizeof(sz_scan),
  713.                                      sz_scan);
  714.  
  715.                  us_scan = atoi(sz_scan);
  716.  
  717.                  WinDismissDlg(hWndDlg, TRUE);
  718.                  break;
  719.  
  720.             case DID_CANCEL: /* Button text: "Cancel"                      */
  721.                  /* Ignore data values entered into the dialog controls    */
  722.                  /* and dismiss the dialog window                          */
  723.                  WinDismissDlg(hWndDlg, FALSE);
  724.                  break;
  725.  
  726.             case 260: /* Button text: "Help"                               */
  727.                  break;
  728.  
  729.            }
  730.          break; /* End of WM_COMMAND */
  731.                                
  732.     case WM_CLOSE:
  733.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  734.          break; /* End of WM_CLOSE */
  735.            
  736.     case WM_FAILEDVALIDATE:
  737.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  738.          sfValidate = FALSE;
  739.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  740.          sfValidate = TRUE;
  741.          return((MRESULT)TRUE);
  742.          break; /* End of WM_FAILEDVALIDATE */
  743.  
  744.     default:
  745.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  746.          break;
  747.    }
  748.  return FALSE;
  749. } /* End of INTERVALMsgProc */
  750.  
  751.  
  752. /***************************************************************************/
  753. /*                                                                         */
  754. /* Dialog Window Procedure                                                 */
  755. /*                                                                         */
  756. /* This procedure is associated with the dialog box that is included in    */
  757. /* the function name of the procedure. It provides the service routines    */
  758. /* for the events (messages) that occur because the end user operates      */
  759. /* one of the dialog box's buttons, entry fields, or controls.             */
  760. /*                                                                         */
  761. /* The SWITCH statement in the function distributes the dialog box         */
  762. /* messages to the respective service routines, which are set apart by     */
  763. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  764. /* procedures must provide an appropriate service routine for their end    */
  765. /* user initiated messages as well as for the general PM messages (like    */
  766. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  767. /* which there is no programmed CASE condition (no service routine),       */
  768. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  769. /* disposed of by PM.                                                      */
  770. /*                                                                         */
  771. /***************************************************************************/
  772.  
  773. MRESULT EXPENTRY FILESMsgProc(hWndDlg, message, mp1, mp2)
  774. HWND hWndDlg;
  775. USHORT message;
  776. MPARAM mp1;
  777. MPARAM mp2;
  778.  static SHORT sfValidate = TRUE;
  779.  INT    i;
  780.  static HWND  hWndParent;
  781.           
  782.  switch(message)
  783.    {
  784.     case WM_INITDLG:
  785.          hWndParent = (HWND)mp2;
  786.          cwCenter(hWndDlg, (HWND)hWndParent);
  787.  
  788.          bit_flag.append = FALSE;
  789.          bit_flag.over = FALSE;
  790.          bit_flag.none = TRUE;
  791.  
  792.          break; /* End of WM_INITDLG */
  793.    
  794.     case WM_CONTROL:
  795.          switch(SHORT1FROMMP(mp1))
  796.            {
  797.             case 256: /* Radiobutton text: "~Append"                       */
  798.                  bit_flag.append = TRUE;
  799.                  bit_flag.over = FALSE;
  800.                  bit_flag.none = FALSE;
  801.                  break;
  802.  
  803.             case 257: /* Radiobutton text: "Over~write"                    */
  804.                  bit_flag.over = TRUE;
  805.                  bit_flag.none = FALSE;
  806.                  bit_flag.append = FALSE;
  807.                  break;
  808.  
  809.             case 258: /* Radiobutton text: "~None"                         */
  810.                  bit_flag.none = TRUE;
  811.                  bit_flag.append = FALSE;
  812.                  bit_flag.over = FALSE;
  813.                  break;
  814.  
  815.            }
  816.          break; /* End of WM_CONTROL */
  817.    
  818.     case WM_COMMAND:
  819.          switch(SHORT1FROMMP(mp1))
  820.            {
  821.             case DID_OK: /* Button text: "Ok"                              */
  822.                  if (bit_flag.append)
  823.                     {
  824.                     if((spyfile = fopen(sz_log, "a")) == NULL)
  825.                        {
  826.                        perror("Can't open log file...");
  827.                        }
  828.                     }
  829.  
  830.                  if (bit_flag.over)
  831.                     {
  832.                     if((spyfile = fopen(sz_log, "w")) == NULL)
  833.                        {
  834.                        perror("Can't open log file...");
  835.                        }
  836.                     }
  837.  
  838.                  WinDismissDlg(hWndDlg, TRUE);
  839.                  break;
  840.  
  841.             case DID_CANCEL: /* Button text: "Cancel"                      */
  842.                  /* Ignore data values entered into the dialog controls    */
  843.                  /* and dismiss the dialog window                          */
  844.                  WinDismissDlg(hWndDlg, FALSE);
  845.                  break;
  846.  
  847.             case 261: /* Button text: "Help"                               */
  848.                  break;
  849.  
  850.            }
  851.          break; /* End of WM_COMMAND */
  852.                                
  853.     case WM_CLOSE:
  854.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  855.          break; /* End of WM_CLOSE */
  856.            
  857.     case WM_FAILEDVALIDATE:
  858.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  859.          sfValidate = FALSE;
  860.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  861.          sfValidate = TRUE;
  862.          return((MRESULT)TRUE);
  863.          break; /* End of WM_FAILEDVALIDATE */
  864.  
  865.     default:
  866.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  867.          break;
  868.    }
  869.  return FALSE;
  870. } /* End of FILESMsgProc */
  871.  
  872.  
  873. /***************************************************************************/
  874. /*                                                                         */
  875. /* Dialog Window Procedure                                                 */
  876. /*                                                                         */
  877. /* This procedure is associated with the dialog box that is included in    */
  878. /* the function name of the procedure. It provides the service routines    */
  879. /* for the events (messages) that occur because the end user operates      */
  880. /* one of the dialog box's buttons, entry fields, or controls.             */
  881. /*                                                                         */
  882. /* The SWITCH statement in the function distributes the dialog box         */
  883. /* messages to the respective service routines, which are set apart by     */
  884. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  885. /* procedures must provide an appropriate service routine for their end    */
  886. /* user initiated messages as well as for the general PM messages (like    */
  887. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  888. /* which there is no programmed CASE condition (no service routine),       */
  889. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  890. /* disposed of by PM.                                                      */
  891. /*                                                                         */
  892. /***************************************************************************/
  893.  
  894. MRESULT EXPENTRY DATABASEMsgProc(hWndDlg, message, mp1, mp2)
  895. HWND hWndDlg;
  896. USHORT message;
  897. MPARAM mp1;
  898. MPARAM mp2;
  899.  static SHORT sfValidate = TRUE;
  900.  INT    i, us_item_index;
  901.  static HWND  hWndParent;
  902.  static USHORT rc;
  903.  char   *pspace;
  904.           
  905.  switch(message)
  906.    {
  907.     case WM_INITDLG:
  908.          hWndParent = (HWND)mp2;
  909.          cwCenter(hWndDlg, (HWND)hWndParent);
  910.          hWndDbDlg = hWndDlg;
  911.  
  912.          SQLGDOPS('0', &us_hand_dir, &us_count_dir, &sqlca);
  913.  
  914.          strcpy(sz_alias[0], "--New--");
  915.  
  916.          for(i=1;i<us_count_dir+1;i++)
  917.             {
  918.             SQLGDGNE(us_hand_dir, &st_info, &sqlca);
  919.             strncpy(sz_alias[i], st_info->alias, 8);
  920.             sz_alias[i][8] = '\0';
  921.             }
  922.  
  923.          SQLGDCLS(us_hand_dir, &sqlca);
  924.  
  925.          for(i=0;i<us_count_dir+1;i++)
  926.             {
  927.             WinSendDlgItemMsg(hWndDlg,
  928.                                   256,
  929.                         LM_INSERTITEM,
  930.               MPFROM2SHORT(LIT_END,0),
  931.                 MPFROMP(sz_alias[i]));
  932.             } 
  933.          break;
  934.    
  935.     case WM_CONTROL:
  936.          switch(SHORT1FROMMP(mp1))
  937.            {
  938.             case 256: /* List box                                          */
  939.                  us_item_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
  940.                                                                256,
  941.                                                  LM_QUERYSELECTION,
  942.                                                        (short)NULL,
  943.                                                       (short)NULL);
  944.                        
  945.                   if (us_item_index == LIT_NONE)
  946.                     {
  947.                     strcpy(sz_dbase,"--New--");
  948.                     }
  949.                  else
  950.                     {
  951.                     strcpy(sz_dbase, sz_alias[us_item_index]);
  952.  
  953.                     if ((pspace = strchr(sz_dbase, ' ')) != NULL)
  954.                        {
  955.                        *pspace = '\0';
  956.                        }
  957.  
  958.                     sz_dbase[8] = '\0';
  959.                     strcpy(sz_log, sz_dbase);
  960.                     sz_log[8] = '\0';
  961.                     strcat(sz_log, ".LOG");
  962.  
  963.                     strcpy(sz_new_title, "Ludospy on ");
  964.                     strcat(sz_new_title, sz_dbase);
  965.  
  966.                     WinSetWindowText(hWndFrame, sz_new_title);
  967.  
  968. /*
  969.                     SQLGSTRD(0, strlen(sz_dbase), 'S', &sqlca, 0, sz_dbase);
  970.  
  971.                     if (sqlca.sqlcode != 0)
  972.                        {
  973.                        DosBeep(500,500);
  974.                        }
  975.  
  976.                     st_auth.sql_authorizations_len = sizeof(st_auth);
  977.  
  978.                     SQLGADAU(p_auth, &sqlca);
  979.  
  980.                     if (sqlca.sqlcode != 0)
  981.                        {
  982.                        DosBeep(500,500);
  983.                        }
  984. */
  985.                     }
  986.  
  987.                  break;
  988.  
  989.            }
  990.          break;
  991.    
  992.     case WM_COMMAND:
  993.          switch(SHORT1FROMMP(mp1))
  994.            {
  995.             case DID_OK: /* Button text: "Ok"                              */
  996.                  WinDestroyWindow(hWndDlg);
  997.                  hWndDATABASE = 0;
  998.               
  999.                  if ((strcmp(sz_dbase, "--New--")) == 0)
  1000.                     {
  1001.                     rc = WinDlgBox(HWND_DESKTOP, hWndDlg,
  1002.                            (PFNWP)CATMsgProc,
  1003.                            0, IDLG_CAT, (PBYTE)hWndParent);
  1004.  
  1005.                     if (rc)
  1006.                        {
  1007.                         WinSendDlgItemMsg(hWndDlg,
  1008.                                               256,
  1009.                                     LM_INSERTITEM,
  1010.                           MPFROM2SHORT(LIT_END,0),
  1011.                            MPFROMP(sz_alias[us_count_dir]));
  1012.                        }
  1013.                     }
  1014.                  else
  1015.                     {
  1016.                     bit_flag.noconn = FALSE;
  1017.                     rc = WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, /* hWndDlg */
  1018.                            NULL, NULL,             /* 0, (PFNWP)STATUSMsgProc, */
  1019.                            IDLG_STATUS, NULL);     /*  (PBYTE)hWndParent);  */
  1020.                     
  1021.                     if (bit_flag.noconn)
  1022.                        {
  1023.                        WinShowWindow(hWndDbDlg,
  1024.                                   (BOOL)FALSE);
  1025.                    
  1026.                        WinDlgBox(HWND_DESKTOP, hWndDlg, (PFNWP)NO_CONMsgProc,
  1027.                                  0, IDLG_NO_CON, (PBYTE)hWndDlg);
  1028.  
  1029.                        WinShowWindow(hWndDbDlg,
  1030.                                    (BOOL)TRUE);
  1031.                        }
  1032.  
  1033.                     if (rc)
  1034.                        {
  1035.                        WinDismissDlg(hWndDlg, FALSE);
  1036.                        }
  1037.                     }
  1038.                  break;
  1039.  
  1040.             case DID_CANCEL: /* Button text: "Cancel"                      */
  1041.                  /* Ignore data values entered into the dialog controls    */
  1042.                  /* and dismiss the dialog window                          */
  1043.                  WinDestroyWindow(hWndDlg);
  1044.                  hWndDATABASE = 0;
  1045.                  break;
  1046.  
  1047.             case 259: /* Button text: "Help"                               */
  1048.                  break;
  1049.  
  1050.            }
  1051.          break; /* End of WM_COMMAND */
  1052.                                
  1053.     case WM_CLOSE:
  1054.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  1055.          break; /* End of WM_CLOSE */
  1056.            
  1057.     case WM_FAILEDVALIDATE:
  1058.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1059.          sfValidate = FALSE;
  1060.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1061.          sfValidate = TRUE;
  1062.          return((MRESULT)TRUE);
  1063.          break; /* End of WM_FAILEDVALIDATE */
  1064.  
  1065.     default:
  1066.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1067.          break;
  1068.    }
  1069.  return FALSE;
  1070. } /* End of DATABASEMsgProc */
  1071.  
  1072.  
  1073. /***************************************************************************/
  1074. /*                                                                         */
  1075. /* Dialog Window Procedure                                                 */
  1076. /*                                                                         */
  1077. /* This procedure is associated with the dialog box that is included in    */
  1078. /* the function name of the procedure. It provides the service routines    */
  1079. /* for the events (messages) that occur because the end user operates      */
  1080. /* one of the dialog box's buttons, entry fields, or controls.             */
  1081. /*                                                                         */
  1082. /* The SWITCH statement in the function distributes the dialog box         */
  1083. /* messages to the respective service routines, which are set apart by     */
  1084. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  1085. /* procedures must provide an appropriate service routine for their end    */
  1086. /* user initiated messages as well as for the general PM messages (like    */
  1087. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  1088. /* which there is no programmed CASE condition (no service routine),       */
  1089. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  1090. /* disposed of by PM.                                                      */
  1091. /*                                                                         */
  1092. /***************************************************************************/
  1093.  
  1094. MRESULT EXPENTRY STATUSMsgProc(hWndDlg, message, mp1, mp2)
  1095. HWND hWndDlg;
  1096. USHORT message;
  1097. MPARAM mp1;
  1098. MPARAM mp2;
  1099.  HPS hPS;              /* Handle for the Presentation Space              */
  1100.  RECTL rDlg;           /* Handle to rectangle formed by client area      */
  1101.  static SHORT sfValidate = TRUE;
  1102.  INT    i, j, k;
  1103.  static HWND  hWndParent;
  1104.  static HWND  hWndLBox;
  1105.  static USHORT cols[] = { 3, 70, 80, 9, 9, 9, 9, 9, 9, 9, 20, 9, 9, 9, 9, 9, 9, 9, 20, 9, 9, 9, 9, 9, 9, 9, 32, 28, 45 };
  1106.  char   sz_temp[9];
  1107.  char   *p_til;
  1108.  char   *p_colon;
  1109.  short  us_len;
  1110.  USHORT us_ret, us_ret_wch;
  1111.  PBYTE  p_stack;
  1112.  PBYTE  p_wch_stack;
  1113.           
  1114.  switch(message)
  1115.    {
  1116.     case WM_INITDLG:
  1117.  
  1118.          hWndParent = (HWND)mp2;
  1119.          cwCenter(hWndDlg, (HWND)hWndParent);
  1120.          hWndReFresh = hWndDlg;
  1121.          p_stack = stack;
  1122.          p_wch_stack = wch_stack;
  1123.          bit_flag.tend = FALSE;
  1124.  
  1125.     case WM_REDRAW:
  1126.  
  1127.          bit_flag.draw = TRUE;
  1128.          WinSendDlgItemMsg(hWndDlg, 256, LM_DELETEALL, 0L, 0L);
  1129.          WinSetPointer(HWND_DESKTOP,
  1130.              WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE));
  1131.  
  1132.          bit_flag.time = FALSE;
  1133.          us_ret_wch = _beginthread((PVOID)wch_thread,
  1134.                                   p_wch_stack,
  1135.                                   STACK_SIZE,
  1136.                                   ARGS);
  1137.  
  1138.          us_db_count = 1;
  1139.          SQLGOPST(3, 1, strlen(sz_dbase), &sz_dbase, &us_db_count,
  1140.                                           &basestat, &sqlca);
  1141.  
  1142.          if (sqlca.sqlcode != 0)
  1143.             {
  1144.             db_crash();
  1145.             }
  1146.  
  1147.          if (!bit_flag.none)
  1148.             {
  1149.             write_db_stats();
  1150.             }
  1151.  
  1152.          if (basestat.connects == 0)
  1153.             {
  1154.             bit_flag.noconn = TRUE;
  1155.  
  1156.             SQLGFREE(&sqlca);
  1157.             if (sqlca.sqlcode != 0)
  1158.                {
  1159.                db_crash();
  1160.                }
  1161.  
  1162.             WinDismissDlg(hWndDlg, FALSE);
  1163.             }
  1164.          else
  1165.             {
  1166.             SQLGUSER(strlen(sz_dbase), &sz_dbase, &basestat.ustat, &sqlca);
  1167.             if ((sqlca.sqlcode != 0) && (sqlca.sqlcode != -1203))
  1168.                {
  1169.                db_crash();
  1170.                }
  1171.  
  1172.             SQLGFREE(&sqlca);
  1173.             if (sqlca.sqlcode != 0)
  1174.                {
  1175.                db_crash();
  1176.                }
  1177.  
  1178.             bit_flag.time = TRUE;
  1179.             sort_users();
  1180.  
  1181.             if (!bit_flag.none)
  1182.                {
  1183.                write_user_stats();
  1184.                fclose(spyfile);
  1185.                }
  1186.  
  1187.             if (basestat.location == 'R')
  1188.                {
  1189.                strcpy(sz_title, "Remote: ");
  1190.                }
  1191.             else
  1192.                {
  1193.                strcpy(sz_title, "Local: ");
  1194.                }
  1195.  
  1196.             strncat(sz_title, basestat.db_name, 8);
  1197.             strcat(sz_title, "  Alias: ");
  1198.             strncat(sz_title, basestat.db_alias, 8);
  1199.  
  1200.             if (basestat.location == 'R')
  1201.                {
  1202.                strcat(sz_title, "  Node: ");
  1203.                strncat(sz_title, basestat.node, 8);
  1204.                }
  1205.  
  1206.             strcat(sz_title, "  Connects: ");
  1207.             itoa(basestat.connects, sz_conn, 10);
  1208.             strcat(sz_title, sz_conn);
  1209.  
  1210.             WinSetWindowText(hWndDlg, sz_title);
  1211.     
  1212.             for(j=0;j<basestat.connects;j++)
  1213.                {
  1214.                memset(sz_trans_con, '\0', sizeof(sz_trans_con));
  1215.                memset(sz_req_con, '\0', sizeof(sz_req_con));
  1216.                memset(sz_req_cur, '\0', sizeof(sz_req_cur));
  1217.                memset(sz_temp, '\0', sizeof(sz_temp));
  1218.                memset(sz_stats, '\0', sizeof(sz_stats));
  1219.  
  1220.                ltoa(basestat.ustat[j].con_trans, sz_trans_con, 10);
  1221.                ltoa(basestat.ustat[j].con_reqs, sz_req_con, 10);
  1222.                ltoa(basestat.ustat[j].cur_reqs, sz_req_cur, 10);
  1223.  
  1224.                strcpy(sz_temp, sz_trans_con);
  1225.                us_len = strlen(sz_trans_con);
  1226.  
  1227.                for(k=0;k<(8 - us_len);k++)
  1228.                   {
  1229.                   sz_trans_con[k] = ' ';
  1230.                   }
  1231.  
  1232.                strcat(sz_trans_con, sz_temp);
  1233.                sz_trans_con[8] = '\0';
  1234.       
  1235.                strcpy(sz_temp, sz_req_con);
  1236.                us_len = strlen(sz_req_con);
  1237.  
  1238.                for(k=0;k<(8 - us_len);k++)
  1239.                   {
  1240.                   sz_req_con[k] = ' ';
  1241.                   }
  1242.  
  1243.                strcat(sz_req_con, sz_temp);
  1244.                sz_req_con[8] = '\0';
  1245.  
  1246.  
  1247.                strcpy(sz_temp, sz_req_cur);
  1248.                us_len = strlen(sz_req_cur);
  1249.  
  1250.                for(k=0;k<(8 - us_len);k++)
  1251.                   {
  1252.                   sz_req_cur[k] = ' ';
  1253.                   }
  1254.  
  1255.                strcat(sz_req_cur, sz_temp);
  1256.                sz_req_cur[8] = '\0';
  1257.  
  1258.  
  1259.                strcpy(sz_stats, "~");
  1260.                strncat(sz_stats, basestat.ustat[j].authid, 8);
  1261.                strcat(sz_stats, "~");
  1262.                strncat(sz_stats, basestat.ustat[j].node, 8);
  1263.                strcat(sz_stats, "~");
  1264.  
  1265.                if (( p_til = strrchr(sz_stats, '~')) != NULL)
  1266.                   {
  1267.                   p_til++;
  1268.                   for(k=0;k<strlen(sz_trans_con);k++)
  1269.                      {
  1270.                      *p_til = sz_trans_con[k];
  1271.                      p_til++;
  1272.                      *p_til = '~';
  1273.                      p_til++;
  1274.                      }
  1275.                   }
  1276.  
  1277.                if (( p_til = strrchr(sz_stats, '~')) != NULL)
  1278.                   {
  1279.                   p_til++;
  1280.                   for(k=0;k<strlen(sz_req_con);k++)
  1281.                      {
  1282.                      *p_til = sz_req_con[k];
  1283.                      p_til++;
  1284.                      *p_til = '~';
  1285.                      p_til++;
  1286.                      }
  1287.                   }
  1288.  
  1289.                if (( p_til = strrchr(sz_stats, '~')) != NULL)
  1290.                   {
  1291.                   p_til++;
  1292.                   for(k=0;k<strlen(sz_req_cur);k++)
  1293.                      {
  1294.                      *p_til = sz_req_cur[k];
  1295.                      p_til++;
  1296.                      *p_til = '~';
  1297.                      p_til++;
  1298.                      }
  1299.                   }
  1300.  
  1301.                if (basestat.ustat[j].trans_state == 'S')
  1302.                   {
  1303.                   strcat(sz_stats, "S");
  1304.                   }
  1305.  
  1306.                if (basestat.ustat[j].trans_state == 'R')
  1307.                   {
  1308.                   strcat(sz_stats, "R");
  1309.                   }
  1310.  
  1311.                if (basestat.ustat[j].trans_state == 'C')
  1312.                   {
  1313.                   strcat(sz_stats, "C");
  1314.                   }
  1315.  
  1316.                strcat(sz_stats, "~");
  1317.  
  1318.                if (basestat.ustat[j].lock_state == 'N')
  1319.                   {
  1320.                   strcat(sz_stats, "N");
  1321.                   }
  1322.  
  1323.                if (basestat.ustat[j].lock_state == 'W')
  1324.                   {
  1325.                   strcat(sz_stats, "W");
  1326.                   }
  1327.  
  1328.                get_time();
  1329.  
  1330.                con_time = bintime - basestat.ustat[j].connect_time;
  1331.                out_time = localtime(&con_time);
  1332.                sprintf(sz_time_out, "%s", asctime(out_time));
  1333.                p_colon = strchr(sz_time_out, ':');
  1334.                p_colon--;
  1335.                p_colon--;
  1336.                strcat(sz_stats, "~");
  1337.                strncat(sz_stats, p_colon, 8);
  1338.  
  1339.                WinSendDlgItemMsg(hWndDlg,
  1340.                                      256,
  1341.                            LM_INSERTITEM,
  1342.                  MPFROM2SHORT(LIT_END,0),
  1343.                       MPFROMP(sz_stats));
  1344.  
  1345.                } /* end of for j */
  1346.             }
  1347.  
  1348.          WinSetPointer(HWND_DESKTOP,
  1349.             WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,FALSE));
  1350.  
  1351.          if (message == WM_INITDLG)
  1352.             {
  1353.             us_ret = _beginthread((PVOID)refresh_thread,
  1354.                                   p_stack,
  1355.                                   STACK_SIZE,
  1356.                                   ARGS);
  1357.             }
  1358.  
  1359.          bit_flag.draw = FALSE;
  1360.  
  1361.          break; /* End of WM_INITDLG  and WM_REDRAW */
  1362.    
  1363.         case WM_MEASUREITEM:
  1364.                 return( LimitLBox( hWndDlg, 1750 ) );
  1365.             break;
  1366.  
  1367.         case WM_DRAWITEM:
  1368.             if ( SHORT1FROMMP( mp1 ) != 256)
  1369.                { 
  1370.                return ( 0L );
  1371.                }
  1372.  
  1373.             return( AlignLBox( hWndDlg, 256, cols, mp2 ) );
  1374.             break;
  1375.    
  1376.     case WM_CONTROL:
  1377.          switch(SHORT1FROMMP(mp1))
  1378.            {
  1379.             case 256: /* List box                                          */
  1380.                  {
  1381.                  }
  1382.                  break;
  1383.  
  1384.            }
  1385.          break; /* End of WM_CONTROL */
  1386.    
  1387.     case WM_COMMAND:
  1388.          switch(SHORT1FROMMP(mp1))
  1389.            {
  1390.             case DID_OK: /* Button text: "Ok"                              */
  1391.  
  1392.                  WinShowWindow(hWndDbDlg,
  1393.                              (BOOL)FALSE);
  1394.  
  1395.                  WinDismissDlg(hWndDlg, TRUE);
  1396.                  break;
  1397.  
  1398.             case DID_CANCEL: /* Button text: "Cancel"                      */
  1399.                  /* Ignore data values entered into the dialog controls    */
  1400.                  /* and dismiss the dialog window                          */
  1401.                  bit_flag.tend = TRUE;
  1402.                  WinDismissDlg(hWndDlg, FALSE);
  1403.                  break;
  1404.  
  1405.             case 257: /* Button text: "Help"                               */
  1406.                  break;
  1407.  
  1408.            }
  1409.          break; /* End of WM_COMMAND */
  1410.                                
  1411. //    case WM_PAINT:    /* code for the window's client area               */
  1412. //         /* Obtain a handle to a cache presentation space                */
  1413. //
  1414. //         hWndLBox = WinWindowFromID(hWndDlg, 256);
  1415. //
  1416. //         hPS = WinBeginPaint(hWndLBox, 0, 0);
  1417. //
  1418. //         /* Determine the size of the client area                        */
  1419. //         WinQueryWindowRect(hWndLBox, &rDlg);
  1420. //
  1421. //         /* Fill the background with the default background color        */
  1422. //         WinFillRect(hPS, &rDlg, CLR_BLUE);
  1423. //
  1424. //         /* return presentation space to state before WinBeginPaint      */
  1425. //         WinEndPaint(hPS);
  1426. //         break; /* End of WM_PAINT */
  1427.                                
  1428.     case WM_CLOSE:
  1429.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  1430.          break; /* End of WM_CLOSE */
  1431.            
  1432.     case WM_FAILEDVALIDATE:
  1433.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1434.          sfValidate = FALSE;
  1435.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1436.          sfValidate = TRUE;
  1437.          return((MRESULT)TRUE);
  1438.          break; /* End of WM_FAILEDVALIDATE */
  1439.  
  1440.     default:
  1441.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1442.          break;
  1443.    }
  1444.  return FALSE;
  1445. } /* End of STATUSMsgProc */
  1446.  
  1447.  
  1448. /***************************************************************************/
  1449. /*                                                                         */
  1450. /* Dialog Window Procedure                                                 */
  1451. /*                                                                         */
  1452. /* This procedure is associated with the dialog box that is included in    */
  1453. /* the function name of the procedure. It provides the service routines    */
  1454. /* for the events (messages) that occur because the end user operates      */
  1455. /* one of the dialog box's buttons, entry fields, or controls.             */
  1456. /*                                                                         */
  1457. /* The SWITCH statement in the function distributes the dialog box         */
  1458. /* messages to the respective service routines, which are set apart by     */
  1459. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  1460. /* procedures must provide an appropriate service routine for their end    */
  1461. /* user initiated messages as well as for the general PM messages (like    */
  1462. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  1463. /* which there is no programmed CASE condition (no service routine),       */
  1464. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  1465. /* disposed of by PM.                                                      */
  1466. /*                                                                         */
  1467. /***************************************************************************/
  1468.  
  1469. MRESULT EXPENTRY CATMsgProc(hWndDlg, message, mp1, mp2)
  1470. HWND hWndDlg;
  1471. USHORT message;
  1472. MPARAM mp1;
  1473. MPARAM mp2;
  1474.  static SHORT sfValidate = TRUE;
  1475.  INT           i, us_item_index, us_item_len;
  1476.  INT           us_node_index;
  1477.  static HWND  hWndParent;
  1478.  CATStruct FAR *Cat;
  1479.  static USHORT rc;
  1480.  char          *pspace;
  1481.  static char   ch_type; 
  1482.  static char   ch_drive;
  1483.           
  1484.  switch(message)
  1485.    {
  1486.     case WM_INITDLG:
  1487.          Cat = (CATStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CAT);
  1488.          memset(sz_rds_name, '\0', sizeof(sz_rds_name));
  1489.          hWndParent = (HWND)mp2;
  1490.          cwCenter(hWndDlg, (HWND)hWndParent);
  1491.          /* Initialize radio button control: YourWindowsTitleGoesHere      */
  1492.          WinPostMsg(hWndDlg, WM_CONTROL,
  1493.                     MPFROMSHORT(Cat->YourWindowsTitleGoesHere), 0L);
  1494.  
  1495.          WinSendDlgItemMsg(hWndDlg, 262, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
  1496.          WinSendDlgItemMsg(hWndDlg, 263, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
  1497.          WinSendDlgItemMsg(hWndDlg, 264, EM_SETTEXTLIMIT, (MPARAM)30, NULL);
  1498.          WinSendDlgItemMsg(hWndDlg, 270, EM_SETTEXTLIMIT, (MPARAM)1, NULL);
  1499.  
  1500.          SQLGNOPS(&us_hand_node, &us_count_node, &sqlca);
  1501.  
  1502.          strcpy(sz_node[0], "--New--");
  1503.  
  1504.          for(i=1;i<us_count_node+1;i++)
  1505.             {
  1506.             SQLGNGNE(us_hand_node, &st_node, &sqlca);
  1507.             strncpy(sz_node[i], st_node->nodename, 8);
  1508.             sz_node[i][8] = '\0';
  1509.             }
  1510.  
  1511.          SQLGNCLS(us_hand_node, &sqlca);
  1512.  
  1513.          for(i=0;i<us_count_node+1;i++)
  1514.             {
  1515.             WinSendDlgItemMsg(hWndDlg,
  1516.                                   265,
  1517.                         LM_INSERTITEM,
  1518.               MPFROM2SHORT(LIT_END,0),
  1519.                 MPFROMP(sz_node[i]));
  1520.             }
  1521.  
  1522.          break; /* End of WM_INITDLG */
  1523.    
  1524.     case WM_CONTROL:
  1525.          switch(SHORT1FROMMP(mp1))
  1526.            {
  1527.             case 256: /* Radiobutton text: "Local"                         */
  1528.                  cwCheckDlgItem(hWndDlg, 256, TRUE);
  1529.                  cwCheckDlgItem(hWndDlg, 257, FALSE);
  1530.                  ch_type = '0';
  1531.                  ch_drive = '\0';
  1532.                  break;
  1533.  
  1534.             case 257: /* Radiobutton text: "Remote"                        */
  1535.                  cwCheckDlgItem(hWndDlg, 257, TRUE);
  1536.                  cwCheckDlgItem(hWndDlg, 256, FALSE);
  1537.                  ch_type = '1';
  1538.                  ch_drive = '\0';
  1539.                  break;
  1540.  
  1541.             case 262: /* Entry field                                       */
  1542.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1543.                    { 
  1544.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1545.                          break;
  1546.  
  1547.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1548.                          break;
  1549.  
  1550.                     default: /* Default other messages                     */
  1551.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1552.                          break;
  1553.                    }
  1554.                  break;
  1555.  
  1556.             case 263: /* Entry field                                       */
  1557.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1558.                    { 
  1559.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1560.                          break;
  1561.  
  1562.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1563.                          break;
  1564.  
  1565.                     default: /* Default other messages                     */
  1566.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1567.                          break;
  1568.                    }
  1569.                  break;
  1570.  
  1571.             case 264: /* Entry field                                       */
  1572.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1573.                    { 
  1574.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1575.                          break;
  1576.  
  1577.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1578.                          break;
  1579.  
  1580.                     default: /* Default other messages                     */
  1581.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1582.                          break;
  1583.                    }
  1584.                  break;
  1585.  
  1586.             case 270: /* Entry field                                       */
  1587.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1588.                    { 
  1589.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1590.                          break;
  1591.  
  1592.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1593.                          break;
  1594.  
  1595.                     default: /* Default other messages                     */
  1596.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1597.                          break;
  1598.                    }
  1599.                  break;
  1600.  
  1601.             case 265: /* List box                                          */
  1602.                  {
  1603.                  us_node_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
  1604.                                                                265,
  1605.                                                  LM_QUERYSELECTION,
  1606.                                                        (short)NULL,
  1607.                                                       (short)NULL);
  1608.                        
  1609.                   if (us_node_index == LIT_NONE)
  1610.                     {
  1611.                     strcpy(sz_rds_name,"--New--");
  1612.                     }
  1613.                  else
  1614.                     {
  1615.                     strcpy(sz_rds_name, sz_node[us_node_index]);
  1616.  
  1617.                     if ((pspace = strchr(sz_rds_name, ' ')) != NULL)
  1618.                        {
  1619.                        *pspace = '\0';
  1620.                        }
  1621.  
  1622.                     sz_rds_name[8] = '\0';
  1623.                     }
  1624.                  }
  1625.                  break;
  1626.            }
  1627.          break; /* End of WM_CONTROL */
  1628.    
  1629.     case WM_COMMAND:
  1630.          switch(SHORT1FROMMP(mp1))
  1631.            {
  1632.             case DID_OK: /* Button text: "Ok"                              */
  1633.                   Cat = (CATStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CAT);
  1634.                  /* Query radio button for current state, if set then      */
  1635.                  /* set the dialog structure variable to the control ID    */
  1636.                  if (WinSendDlgItemMsg(hWndDlg, 256,
  1637.                                BM_QUERYCHECK, 0L, 0L ))
  1638.                     Cat->YourWindowsTitleGoesHere = 256;
  1639.                  /* Query radio button for current state, if set then      */
  1640.                  /* set the dialog structure variable to the control ID    */
  1641.                  if (WinSendDlgItemMsg(hWndDlg, 257,
  1642.                                BM_QUERYCHECK, 0L, 0L ))
  1643.                     Cat->YourWindowsTitleGoesHere = 257;
  1644.  
  1645.                  if ((strcmp(sz_rds_name, "--New--")) == 0)
  1646.                     {
  1647.                     rc = WinDlgBox(HWND_DESKTOP, hWndDlg,
  1648.                            (PFNWP)NODEMsgProc,
  1649.                            0, IDLG_NODE, (PBYTE)hWndParent);
  1650.  
  1651.                     if (rc)
  1652.                        {
  1653.                         WinSendDlgItemMsg(hWndDlg,
  1654.                                               265,
  1655.                                     LM_INSERTITEM,
  1656.                           MPFROM2SHORT(LIT_END,0),
  1657.                            MPFROMP(sz_node[us_count_node]));
  1658.                        }
  1659.  
  1660.                     break;
  1661.  
  1662.                     }
  1663.  
  1664.                  us_count_dir++;
  1665.  
  1666.                  memset(sz_comment, '\0', sizeof(sz_comment));
  1667.                  memset(sz_db_entry, '\0', sizeof(sz_db_entry));
  1668.                  memset(sz_alias[us_count_dir], '\0',
  1669.                         sizeof(sz_alias[us_count_dir]));
  1670.  
  1671.                  bit_flag.cat = TRUE;
  1672.  
  1673.                  WinQueryDlgItemText(hWndDlg, 262,
  1674.                                      sizeof(sz_db_entry),
  1675.                                      sz_db_entry);
  1676.  
  1677.                  if ((pspace = strrchr(sz_db_entry, ' ')) != NULL)
  1678.                     {
  1679.                     *pspace = '\0';
  1680.                     }
  1681.  
  1682.                  if (sz_db_entry[0] == 0)
  1683.                     {
  1684.                     DosBeep(500,750);
  1685.                     bit_flag.cat = FALSE;
  1686.                     }
  1687.                  else
  1688.                     {
  1689.                     strcpy(sz_dbase, sz_db_entry);
  1690.                     sz_dbase[8] = '\0';
  1691.                     }
  1692.  
  1693.                  strupr(sz_dbase);
  1694.  
  1695.                  WinQueryDlgItemText(hWndDlg, 263,
  1696.                                      sizeof(sz_alias[us_count_dir]),
  1697.                                      sz_alias[us_count_dir]);
  1698.  
  1699.                  if ((pspace = strrchr(sz_alias[us_count_dir], ' ')) != NULL)
  1700.                     {
  1701.                     *pspace = '\0';
  1702.                     }
  1703.  
  1704.                  if (sz_alias[us_count_dir][0] == 0)
  1705.                     {
  1706.                     DosBeep(500,250);
  1707.                     bit_flag.cat = FALSE;
  1708.                     }
  1709.  
  1710.                  strupr(sz_alias[us_count_dir]);
  1711.  
  1712.                  WinQueryDlgItemText(hWndDlg, 264,
  1713.                                      sizeof(sz_comment),
  1714.                                      sz_comment);
  1715.  
  1716. /*
  1717.                  us_node_index = (USHORT)WinSendDlgItemMsg(hWndDlg, 265,
  1718.                      LM_QUERYSELECTION, 0L, 0L);
  1719.  
  1720.                  if (ch_type == '1')
  1721.                     {
  1722.                     strcpy(sz_rds_name, sz_node[us_node_index]);
  1723.                     }
  1724. */
  1725.                  if (bit_flag.cat)
  1726.                     {
  1727.                     SQLGCATD(strlen(sz_comment), 
  1728.                              strlen(sz_rds_name),
  1729.                              strlen(sz_alias[us_count_dir]),
  1730.                              strlen(sz_dbase),
  1731.                              ch_drive,
  1732.                              0,
  1733.                              ch_type,
  1734.                              &sqlca,
  1735.                              sz_comment,
  1736.                              sz_rds_name,
  1737.                              sz_alias[us_count_dir],
  1738.                              sz_dbase);
  1739.  
  1740.                     if (sqlca.sqlcode != 0)
  1741.                        {
  1742.                        DosBeep(500,500);
  1743.                        }
  1744.  
  1745.                  WinDismissDlg(hWndDlg, TRUE);
  1746.                     }
  1747.                  else
  1748.                     {
  1749.                     us_count_dir--;
  1750.                     }
  1751.  
  1752.                  break;
  1753.  
  1754.             case DID_CANCEL: /* Button text: "Cancel"                      */
  1755.                  /* Ignore data values entered into the dialog controls    */
  1756.                  /* and dismiss the dialog window                          */
  1757.                  WinDismissDlg(hWndDlg, FALSE);
  1758.                  break;
  1759.  
  1760.             case 268: /* Button text: "Help"                               */
  1761.                  break;
  1762.  
  1763.            }
  1764.          break; /* End of WM_COMMAND */
  1765.                                
  1766.     case WM_CLOSE:
  1767.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  1768.          break; /* End of WM_CLOSE */
  1769.            
  1770.     case WM_FAILEDVALIDATE:
  1771.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1772.          sfValidate = FALSE;
  1773.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1774.          sfValidate = TRUE;
  1775.          return((MRESULT)TRUE);
  1776.          break; /* End of WM_FAILEDVALIDATE */
  1777.  
  1778.     default:
  1779.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1780.          break;
  1781.    }
  1782.  return FALSE;
  1783. } /* End of CATMsgProc */
  1784.  
  1785.  
  1786. /***************************************************************************/
  1787. /*                                                                         */
  1788. /* Dialog Window Procedure                                                 */
  1789. /*                                                                         */
  1790. /* This procedure is associated with the dialog box that is included in    */
  1791. /* the function name of the procedure. It provides the service routines    */
  1792. /* for the events (messages) that occur because the end user operates      */
  1793. /* one of the dialog box's buttons, entry fields, or controls.             */
  1794. /*                                                                         */
  1795. /* The SWITCH statement in the function distributes the dialog box         */
  1796. /* messages to the respective service routines, which are set apart by     */
  1797. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  1798. /* procedures must provide an appropriate service routine for their end    */
  1799. /* user initiated messages as well as for the general PM messages (like    */
  1800. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  1801. /* which there is no programmed CASE condition (no service routine),       */
  1802. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  1803. /* disposed of by PM.                                                      */
  1804. /*                                                                         */
  1805. /***************************************************************************/
  1806.  
  1807. MRESULT EXPENTRY NODEMsgProc(hWndDlg, message, mp1, mp2)
  1808. HWND hWndDlg;
  1809. USHORT message;
  1810. MPARAM mp1;
  1811. MPARAM mp2;
  1812.  static SHORT sfValidate = TRUE;
  1813.  INT    i;
  1814.  static HWND  hWndParent;
  1815.  char         *pspace;
  1816.           
  1817.  switch(message)
  1818.    {
  1819.     case WM_INITDLG:
  1820.          hWndParent = (HWND)mp2;
  1821.          cwCenter(hWndDlg, (HWND)hWndParent);
  1822.  
  1823.          WinSendDlgItemMsg(hWndDlg, 261, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
  1824.          WinSendDlgItemMsg(hWndDlg, 262, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
  1825.          WinSendDlgItemMsg(hWndDlg, 263, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
  1826.          WinSendDlgItemMsg(hWndDlg, 264, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
  1827.          WinSendDlgItemMsg(hWndDlg, 265, EM_SETTEXTLIMIT, (MPARAM)30, NULL);
  1828.  
  1829.          break; /* End of WM_INITDLG */
  1830.    
  1831.     case WM_CONTROL:
  1832.          switch(SHORT1FROMMP(mp1))
  1833.            {
  1834.             case 261: /* Entry field                                       */
  1835.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1836.                    { 
  1837.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1838.                          break;
  1839.  
  1840.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1841.                          break;
  1842.  
  1843.                     default: /* Default other messages                     */
  1844.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1845.                          break;
  1846.                    }
  1847.                  break;
  1848.  
  1849.             case 262: /* Entry field                                       */
  1850.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1851.                    { 
  1852.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1853.                          break;
  1854.  
  1855.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1856.                          break;
  1857.  
  1858.                     default: /* Default other messages                     */
  1859.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1860.                          break;
  1861.                    }
  1862.                  break;
  1863.  
  1864.             case 263: /* Entry field                                       */
  1865.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1866.                    { 
  1867.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1868.                          break;
  1869.  
  1870.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1871.                          break;
  1872.  
  1873.                     default: /* Default other messages                     */
  1874.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1875.                          break;
  1876.                    }
  1877.                  break;
  1878.  
  1879.             case 264: /* Entry field                                       */
  1880.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1881.                    { 
  1882.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1883.                          break;
  1884.  
  1885.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1886.                          break;
  1887.  
  1888.                     default: /* Default other messages                     */
  1889.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1890.                          break;
  1891.                    }
  1892.                  break;
  1893.  
  1894.             case 265: /* Entry field                                       */
  1895.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1896.                    { 
  1897.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1898.                          break;
  1899.  
  1900.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1901.                          break;
  1902.  
  1903.                     default: /* Default other messages                     */
  1904.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1905.                          break;
  1906.                    }
  1907.                  break;
  1908.  
  1909.            }
  1910.          break; /* End of WM_CONTROL */
  1911.    
  1912.     case WM_COMMAND:
  1913.          switch(SHORT1FROMMP(mp1))
  1914.            {
  1915.             case DID_OK: /* Button text: "Ok"                              */
  1916.  
  1917.                  us_count_node++;
  1918.  
  1919.                  memset(sz_comment, '\0', sizeof(sz_comment));
  1920.                  memset(sz_node[us_count_node], '\0', sizeof(sz_node[us_count_node]));
  1921.                  memset(sz_partner_lu, '\0', sizeof(sz_partner_lu));
  1922.                  memset(sz_local_lu, '\0', sizeof(sz_local_lu));
  1923.                  memset(sz_mode, '\0', sizeof(sz_mode));
  1924.  
  1925.                  bit_flag.node = TRUE;
  1926.      
  1927.                  WinQueryDlgItemText(hWndDlg, 261,
  1928.                                      sizeof(sz_mode),
  1929.                                      sz_mode);
  1930.  
  1931.                  if ((pspace = strrchr(sz_mode, ' ')) != NULL)
  1932.                     {
  1933.                     *pspace = '\0';
  1934.                     }
  1935.  
  1936.                  if (sz_mode[0] == 0)
  1937.                     {
  1938.                     DosBeep(200,500);
  1939.                     bit_flag.node = FALSE;
  1940.                     }
  1941.  
  1942.                  WinQueryDlgItemText(hWndDlg, 262,
  1943.                                      sizeof(sz_local_lu),
  1944.                                      sz_local_lu);
  1945.  
  1946.                  if ((pspace = strrchr(sz_local_lu, ' ')) != NULL)
  1947.                     {
  1948.                     *pspace = '\0';
  1949.                     }
  1950.  
  1951.                  if (sz_local_lu == 0)
  1952.                     {
  1953.                     DosBeep(500,250);
  1954.                     bit_flag.node = FALSE;
  1955.                     }
  1956.  
  1957.                  WinQueryDlgItemText(hWndDlg, 263,
  1958.                                      sizeof(sz_partner_lu),
  1959.                                      sz_partner_lu);
  1960.  
  1961.                  if ((pspace = strrchr(sz_partner_lu, ' ')) != NULL)
  1962.                     {
  1963.                     *pspace = '\0';
  1964.                     }
  1965.  
  1966.                  if (sz_partner_lu == 0)
  1967.                     {
  1968.                     DosBeep(500,250);
  1969.                     bit_flag.node = FALSE;
  1970.                     }
  1971.  
  1972.                  WinQueryDlgItemText(hWndDlg, 264,
  1973.                                      sizeof(sz_node[us_count_node]),
  1974.                                      sz_node[us_count_node]);
  1975.  
  1976.                  if ((pspace = strrchr(sz_nodename, ' ')) != NULL)
  1977.                     {
  1978.                     *pspace = '\0';
  1979.                     }
  1980.  
  1981.                  if (sz_node[us_count_node][0] == 0)
  1982.                     {
  1983.                     DosBeep(500,250);
  1984.                     bit_flag.node = FALSE;
  1985.                     }
  1986.  
  1987.                  WinQueryDlgItemText(hWndDlg, 265,
  1988.                                      sizeof(sz_comment),
  1989.                                      sz_comment);
  1990.  
  1991.                  if ((pspace = strrchr(sz_comment, ' ')) != NULL)
  1992.                     {
  1993.                     *pspace = '\0';
  1994.                     }
  1995.  
  1996.                  if (bit_flag.node)
  1997.                     {
  1998.                     SQLGCATN(strlen(sz_comment), 
  1999.                              strlen(sz_mode),
  2000.                              strlen(sz_partner_lu),
  2001.                              strlen(sz_local_lu),
  2002.                              strlen(sz_node[us_count_node]),
  2003.                              0,
  2004.                              &sqlca,
  2005.                              sz_comment,
  2006.                              sz_mode,
  2007.                              sz_partner_lu,
  2008.                              sz_local_lu,
  2009.                              sz_node[us_count_node]);
  2010.  
  2011.                     if (sqlca.sqlcode != 0)
  2012.                        {
  2013.                        DosBeep(500,500);
  2014.                        }
  2015.                     }
  2016.  
  2017.                  WinDismissDlg(hWndDlg, TRUE);
  2018.                  break;
  2019.  
  2020.             case DID_CANCEL: /* Button text: "Cancel"                      */
  2021.                  /* Ignore data values entered into the dialog controls    */
  2022.                  /* and dismiss the dialog window                          */
  2023.                  WinDismissDlg(hWndDlg, FALSE);
  2024.                  break;
  2025.  
  2026.             case 268: /* Button text: "Help"                               */
  2027.                  break;
  2028.  
  2029.            }
  2030.          break; /* End of WM_COMMAND */
  2031.                                
  2032.     case WM_CLOSE:
  2033.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  2034.          break; /* End of WM_CLOSE */
  2035.            
  2036.     case WM_FAILEDVALIDATE:
  2037.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2038.          sfValidate = FALSE;
  2039.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  2040.          sfValidate = TRUE;
  2041.          return((MRESULT)TRUE);
  2042.          break; /* End of WM_FAILEDVALIDATE */
  2043.  
  2044.     default:
  2045.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  2046.          break;
  2047.    }
  2048.  return FALSE;
  2049. } /* End of NODEMsgProc */
  2050.  
  2051.  
  2052. /***************************************************************************/
  2053. /*                                                                         */
  2054. /* Dialog Window Procedure                                                 */
  2055. /*                                                                         */
  2056. /* This procedure is associated with the dialog box that is included in    */
  2057. /* the function name of the procedure. It provides the service routines    */
  2058. /* for the events (messages) that occur because the end user operates      */
  2059. /* one of the dialog box's buttons, entry fields, or controls.             */
  2060. /*                                                                         */
  2061. /* The SWITCH statement in the function distributes the dialog box         */
  2062. /* messages to the respective service routines, which are set apart by     */
  2063. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  2064. /* procedures must provide an appropriate service routine for their end    */
  2065. /* user initiated messages as well as for the general PM messages (like    */
  2066. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  2067. /* which there is no programmed CASE condition (no service routine),       */
  2068. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  2069. /* disposed of by PM.                                                      */
  2070. /*                                                                         */
  2071. /***************************************************************************/
  2072.  
  2073. MRESULT EXPENTRY NO_CONMsgProc(hWndDlg, message, mp1, mp2)
  2074. HWND hWndDlg;
  2075. USHORT message;
  2076. MPARAM mp1;
  2077. MPARAM mp2;
  2078.  static SHORT sfValidate = TRUE;
  2079.  INT    i;
  2080.  static HWND  hWndParent;
  2081.           
  2082.  switch(message)
  2083.    {
  2084.     case WM_INITDLG:
  2085.          hWndParent = (HWND)mp2;
  2086.          cwCenter(hWndDlg, (HWND)hWndFrame);
  2087.          break; /* End of WM_INITDLG */
  2088.    
  2089.     case WM_CONTROL:
  2090.          switch(SHORT1FROMMP(mp1))
  2091.            {
  2092.            }
  2093.          break; /* End of WM_CONTROL */
  2094.    
  2095.     case WM_COMMAND:
  2096.          switch(SHORT1FROMMP(mp1))
  2097.            {
  2098.             case DID_OK: /* Button text: "Ok"                              */
  2099.                  WinDismissDlg(hWndDlg, TRUE);
  2100.                  break;
  2101.  
  2102.             case 259: /* Button text: "Help"                               */
  2103.                  break;
  2104.  
  2105.            }
  2106.          break; /* End of WM_COMMAND */
  2107.                                
  2108.     case WM_CLOSE:
  2109.          WinDismissDlg(hWndDlg, FALSE);
  2110.          break; /* End of WM_CLOSE */
  2111.            
  2112.     case WM_FAILEDVALIDATE:
  2113.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2114.          sfValidate = FALSE;
  2115.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  2116.          sfValidate = TRUE;
  2117.          return((MRESULT)TRUE);
  2118.          break; /* End of WM_FAILEDVALIDATE */
  2119.  
  2120.     default:
  2121.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  2122.          break;
  2123.    }
  2124.  return FALSE;
  2125. } /* End of NO_CONMsgProc */
  2126.  
  2127.  
  2128. /***************************************************************************/
  2129. /*                                                                         */
  2130. /* Dialog Window Procedure                                                 */
  2131. /*                                                                         */
  2132. /* This procedure is associated with the dialog box that is included in    */
  2133. /* the function name of the procedure. It provides the service routines    */
  2134. /* for the events (messages) that occur because the end user operates      */
  2135. /* one of the dialog box's buttons, entry fields, or controls.             */
  2136. /*                                                                         */
  2137. /* The SWITCH statement in the function distributes the dialog box         */
  2138. /* messages to the respective service routines, which are set apart by     */
  2139. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  2140. /* procedures must provide an appropriate service routine for their end    */
  2141. /* user initiated messages as well as for the general PM messages (like    */
  2142. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  2143. /* which there is no programmed CASE condition (no service routine),       */
  2144. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  2145. /* disposed of by PM.                                                      */
  2146. /*                                                                         */
  2147. /***************************************************************************/
  2148.  
  2149. MRESULT EXPENTRY UN_CATMsgProc(hWndDlg, message, mp1, mp2)
  2150. HWND hWndDlg;
  2151. USHORT message;
  2152. MPARAM mp1;
  2153. MPARAM mp2;
  2154.  static SHORT sfValidate = TRUE;
  2155.  INT    i;
  2156.  static HWND  hWndParent;
  2157.  static char  sz_un_dbase[9];
  2158.  char         *pspace;
  2159.  static short us_cat_index;   
  2160.           
  2161.  switch(message)
  2162.    {
  2163.     case WM_INITDLG:
  2164.          hWndParent = (HWND)mp2;
  2165.          cwCenter(hWndDlg, (HWND)hWndParent);
  2166.  
  2167.          SQLGDOPS('0', &us_hand_dir, &us_count_dir, &sqlca);
  2168.  
  2169.          for(i=0;i<us_count_dir;i++)
  2170.             {
  2171.             SQLGDGNE(us_hand_dir, &st_info, &sqlca);
  2172.             strncpy(sz_un_alias[i], st_info->alias, 8);
  2173.             sz_un_alias[i][8] = '\0';
  2174.  
  2175.             WinSendDlgItemMsg(hWndDlg,
  2176.                                   256,
  2177.                         LM_INSERTITEM,
  2178.               MPFROM2SHORT(LIT_END,0),
  2179.               MPFROMP(sz_un_alias[i]));
  2180.             }
  2181.  
  2182.          SQLGDCLS(us_hand_dir, &sqlca);
  2183.  
  2184.          break; /* End of WM_INITDLG */
  2185.    
  2186.     case WM_CONTROL:
  2187.          switch(SHORT1FROMMP(mp1))
  2188.            {
  2189.             case 256: /* List box                                          */
  2190.                  {
  2191.                  us_cat_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
  2192.                                                               256,
  2193.                                                 LM_QUERYSELECTION,
  2194.                                                       (short)NULL,
  2195.                                                      (short)NULL);
  2196.                        
  2197.                   if (us_cat_index == LIT_NONE)
  2198.                     {
  2199.                     strcpy(sz_dbase,"--New--");
  2200.                     }
  2201.                  else
  2202.                     {
  2203.                     strcpy(sz_un_dbase, sz_un_alias[us_cat_index]);
  2204.  
  2205.                     if ((pspace = strchr(sz_un_dbase, ' ')) != NULL)
  2206.                        {
  2207.                        *pspace = '\0';
  2208.                        }
  2209.  
  2210.                     sz_un_dbase[8] = '\0';
  2211.                     }
  2212.                  }
  2213.                  break;
  2214.  
  2215.            }
  2216.          break; /* End of WM_CONTROL */
  2217.    
  2218.     case WM_COMMAND:
  2219.          switch(SHORT1FROMMP(mp1))
  2220.            {
  2221.             case DID_OK: /* Button text: "Ok"                              */
  2222.  
  2223.                  SQLGUNCD(strlen(sz_un_dbase), &sqlca, sz_un_dbase);
  2224.  
  2225.                  if (sqlca.sqlcode != 0)
  2226.                     {
  2227.                     DosBeep(500,500);
  2228.                     }
  2229.  
  2230.                  WinDismissDlg(hWndDlg, TRUE);
  2231.                  break;
  2232.  
  2233.             case DID_CANCEL: /* Button text: "Cancel"                      */
  2234.                  /* Ignore data values entered into the dialog controls    */
  2235.                  /* and dismiss the dialog window                          */
  2236.                  WinDismissDlg(hWndDlg, FALSE);
  2237.                  break;
  2238.  
  2239.             case 259: /* Button text: "Help"                               */
  2240.                  break;
  2241.  
  2242.            }
  2243.          break; /* End of WM_COMMAND */
  2244.                                
  2245.     case WM_CLOSE:
  2246.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  2247.          break; /* End of WM_CLOSE */
  2248.            
  2249.     case WM_FAILEDVALIDATE:
  2250.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2251.          sfValidate = FALSE;
  2252.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  2253.          sfValidate = TRUE;
  2254.          return((MRESULT)TRUE);
  2255.          break; /* End of WM_FAILEDVALIDATE */
  2256.  
  2257.     default:
  2258.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  2259.          break;
  2260.    }
  2261.  return FALSE;
  2262. } /* End of UN_CATMsgProc */
  2263.  
  2264.  
  2265. /***************************************************************************/
  2266. /*                                                                         */
  2267. /* Dialog Window Procedure                                                 */
  2268. /*                                                                         */
  2269. /* This procedure is associated with the dialog box that is included in    */
  2270. /* the function name of the procedure. It provides the service routines    */
  2271. /* for the events (messages) that occur because the end user operates      */
  2272. /* one of the dialog box's buttons, entry fields, or controls.             */
  2273. /*                                                                         */
  2274. /* The SWITCH statement in the function distributes the dialog box         */
  2275. /* messages to the respective service routines, which are set apart by     */
  2276. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  2277. /* procedures must provide an appropriate service routine for their end    */
  2278. /* user initiated messages as well as for the general PM messages (like    */
  2279. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  2280. /* which there is no programmed CASE condition (no service routine),       */
  2281. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  2282. /* disposed of by PM.                                                      */
  2283. /*                                                                         */
  2284. /***************************************************************************/
  2285.  
  2286. MRESULT EXPENTRY UN_NODEMsgProc(hWndDlg, message, mp1, mp2)
  2287. HWND hWndDlg;
  2288. USHORT message;
  2289. MPARAM mp1;
  2290. MPARAM mp2;
  2291.  static SHORT sfValidate = TRUE;
  2292.  INT          i, us_un_node_index;
  2293.  static HWND  hWndParent;
  2294.  static char  *pspace;
  2295.  static char  sz_un_node[9];
  2296.           
  2297.  switch(message)
  2298.    {
  2299.     case WM_INITDLG:
  2300.          hWndParent = (HWND)mp2;
  2301.          cwCenter(hWndDlg, (HWND)hWndParent);
  2302.  
  2303.          SQLGNOPS(&us_hand_node, &us_count_node, &sqlca);
  2304.  
  2305.          for(i=0;i<us_count_node;i++)
  2306.             {
  2307.             SQLGNGNE(us_hand_node, &st_node, &sqlca);
  2308.             strncpy(sz_un_nodename[i], st_node->nodename, 8);
  2309.             sz_un_nodename[i][8] = '\0';
  2310.  
  2311.             WinSendDlgItemMsg(hWndDlg,
  2312.                                   256,
  2313.                         LM_INSERTITEM,
  2314.               MPFROM2SHORT(LIT_END,0),
  2315.               MPFROMP(sz_un_nodename[i]));
  2316.             }
  2317.  
  2318.          SQLGNCLS(us_hand_node, &sqlca);
  2319.  
  2320.          break; /* End of WM_INITDLG */
  2321.    
  2322.     case WM_CONTROL:
  2323.          switch(SHORT1FROMMP(mp1))
  2324.            {
  2325.             case 256: /* List box                                          */
  2326.                  {
  2327.                  us_un_node_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
  2328.                                                                   256,
  2329.                                                     LM_QUERYSELECTION,
  2330.                                                           (short)NULL,
  2331.                                                          (short)NULL);
  2332.                        
  2333.                   if (us_un_node_index == LIT_NONE)
  2334.                     {
  2335.                     strcpy(sz_rds_name,"--New--");
  2336.                     }
  2337.                  else
  2338.                     {
  2339.                     strcpy(sz_un_node, sz_un_nodename[us_un_node_index]);
  2340.  
  2341.                     if ((pspace = strchr(sz_un_node, ' ')) != NULL)
  2342.                        {
  2343.                        *pspace = '\0';
  2344.                        }
  2345.  
  2346.                     sz_un_node[8] = '\0';
  2347.                     }
  2348.                  }
  2349.                  break;
  2350.  
  2351.            }
  2352.          break; /* End of WM_CONTROL */
  2353.    
  2354.     case WM_COMMAND:
  2355.          switch(SHORT1FROMMP(mp1))
  2356.            {
  2357.             case DID_OK: /* Button text: "Ok"                              */
  2358.                  
  2359.                  SQLGUNCN(strlen(sz_un_node), &sqlca, sz_un_node);
  2360.  
  2361.                  if (sqlca.sqlcode != 0)
  2362.                     {
  2363.                     DosBeep(400,500);
  2364.                     } 
  2365.  
  2366.                  WinDismissDlg(hWndDlg, TRUE);
  2367.                  break;
  2368.  
  2369.             case DID_CANCEL: /* Button text: "Cancel"                      */
  2370.                  /* Ignore data values entered into the dialog controls    */
  2371.                  /* and dismiss the dialog window                          */
  2372.                  WinDismissDlg(hWndDlg, FALSE);
  2373.                  break;
  2374.  
  2375.             case 259: /* Button text: "Help"                               */
  2376.                  break;
  2377.  
  2378.            }
  2379.          break; /* End of WM_COMMAND */
  2380.                                
  2381.     case WM_CLOSE:
  2382.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  2383.          break; /* End of WM_CLOSE */
  2384.            
  2385.     case WM_FAILEDVALIDATE:
  2386.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2387.          sfValidate = FALSE;
  2388.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  2389.          sfValidate = TRUE;
  2390.          return((MRESULT)TRUE);
  2391.          break; /* End of WM_FAILEDVALIDATE */
  2392.  
  2393.     default:
  2394.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  2395.          break;
  2396.    }
  2397.  return FALSE;
  2398. } /* End of UN_NODEMsgProc */
  2399.  
  2400.  
  2401.  
  2402.  
  2403. /***************************************************************************/
  2404. /*                                                                         */
  2405. /* cwRegisterClass Function                                                */
  2406. /*                                                                         */
  2407. /* The following function registers all the classes of all the windows     */
  2408. /* associated with this application. The function returns TRUE if it is    */
  2409. /* successful, otherwise it returns FALSE.                                 */
  2410. /*                                                                         */
  2411. /***************************************************************************/
  2412.  
  2413. INT cwRegisterClass()
  2414. {
  2415.  INT rc;
  2416.  
  2417.  strcpy(szAppName, "LUDOSPY");
  2418.  rc = WinRegisterClass(hAB,             /* Anchor block handle             */
  2419.                       (PCH)szAppName,   /* Name of class being registered  */
  2420.                       (PFNWP)WndProc,   /* Window procedure for class      */
  2421.                       CS_SIZEREDRAW ,
  2422.                       1*sizeof(char FAR *));
  2423.  if (rc == FALSE)
  2424.    return(FALSE);
  2425.  
  2426.  return(TRUE);
  2427. } /* End of cwRegisterClass */
  2428.  
  2429.  
  2430.  
  2431. /***************************************************************************/
  2432. /*                                                                         */
  2433. /* cwCreateWindow Function                                                 */
  2434. /*                                                                         */
  2435. /* The following function is used to create a window (the main window,     */
  2436. /* a child window, an icon window, etc.) and set it's initial size and     */
  2437. /* position. It returns the handle to the frame window.                    */
  2438. /*                                                                         */
  2439. /***************************************************************************/
  2440.  
  2441. HWND cwCreateWindow(
  2442.    HWND   hWndParent,  /* Handle to the parent of the window to be created */
  2443.    ULONG  ctldata,     /* Frame control flags for the window               */
  2444.    PCH    appname,     /* Class name of the window                         */
  2445.    PCH    title,       /* Title of the window                              */
  2446.    USHORT ResID,       /* Resource id value                                */
  2447.    INT    x,           /* Initial horizontal and vertical location         */
  2448.    INT    y,
  2449.    INT    cx,          /* Initial width and height of the window           */
  2450.    INT    cy, 
  2451.    PHWND  hWndClient,  /* Handle to the client area of the window          */
  2452.    ULONG  lfStyle,     /* Frame window style                               */
  2453.    USHORT uSizeStyle)  /* User defined size and location flags             */
  2454. {
  2455.    USHORT rc;            /* accepts return codes from function calls       */
  2456.    HWND   hWndFrame;     /* local handle to created window frame           */
  2457.    USHORT SizeStyle;     /* local window positioning options               */
  2458.    CHAR   MsgBuffer[80]; /* buffer for error messages                      */
  2459.    HPS    hPS;           /* handle to a presentation space                 */
  2460.    int    xmod, ymod;    /* modifiers for sizing                           */
  2461.    #define DLGXMOD  4    /* Dialog units X modulo */
  2462.    #define DLGYMOD  8    /* Dialog units Y modulo */
  2463.    FONTMETRICS fm;       /* structure for determing modifiers              */
  2464.    /* Create the frame window                                              */
  2465.    hWndFrame = WinCreateStdWindow(hWndParent,  /* parent of window         */
  2466.                                   lfStyle,     /* frame window style       */
  2467.                                   &ctldata,    /* frame flags              */
  2468.                                   appname,     /* class name               */
  2469.                                   title,       /* window title             */
  2470.                                   0L,          /* client window style      */
  2471.                                   0,           /* module for resources     */
  2472.                                   ResID,       /* resource id              */
  2473.                                   (HWND FAR *)hWndClient); /* client handle*/
  2474.  
  2475.    /* if hWndFrame is NULL, an error occured when opening the window,      */
  2476.    /*     notify the user and exit this function                           */
  2477.    if(hWndFrame == 0)
  2478.      {
  2479.       WinLoadString(hAB, 0, IDS_ERR_WINDOW_CREATE, 80, MsgBuffer);
  2480.       WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
  2481.                     0, 0, MB_OK|MB_ICONEXCLAMATION);
  2482.       return((HWND)0);
  2483.      }
  2484.  
  2485.    /* set up size options                                                  */
  2486.    SizeStyle = SWP_ACTIVATE | SWP_ZORDER | uSizeStyle;
  2487.  
  2488.    /* if the height, width, intial x or initial y values are non-zero,     */
  2489.    /*     then we will need to set up the modifiers for size and location  */
  2490.    if((cx > 0) || (cy > 0) ||
  2491.       (x > 0)  || (y > 0))
  2492.      {
  2493.       hPS = WinGetPS(HWND_DESKTOP);
  2494.       GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
  2495.       xmod = (INT)fm.lAveCharWidth;
  2496.       ymod = (INT)fm.lMaxBaselineExt;
  2497.       WinReleasePS(hPS);
  2498.      }
  2499.    /* if either the width or the height are non-zero, then the size of the */
  2500.    /*     created window will be changed, set SizeStyle accordingly        */
  2501.    if((cx > 0) || (cy > 0))
  2502.      SizeStyle |= SWP_SIZE;
  2503.    /* set the size and position of the window and activate it              */
  2504.    rc = WinSetWindowPos(hWndFrame, HWND_TOP, 0, 0,
  2505.                         (USHORT)(cx * xmod)/DLGXMOD,
  2506.                         (USHORT)(cy * ymod)/DLGYMOD, SizeStyle);
  2507.  
  2508.    /* if the either the intial x or y position of the window is non-zero,  */
  2509.    /*    set the window to its new position                                */
  2510.    if((x > 0) || (y > 0))
  2511.      rc = WinSetWindowPos(hWndFrame, HWND_TOP,
  2512.                           (USHORT)(x * xmod)/DLGXMOD,
  2513.                           (USHORT)(y * ymod)/DLGYMOD, 0, 0, SWP_MOVE);
  2514.    
  2515.    /* if rc is not set to TRUE then WinSetWindowPos failed, notify the user*/
  2516.    /*     and exit this function                                           */
  2517.    if(!rc)
  2518.      {
  2519.       WinLoadString(hAB, 0, IDS_ERR_WINDOW_POS, 80, MsgBuffer);
  2520.       WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
  2521.                     0, 0, MB_OK|MB_ICONEXCLAMATION);
  2522.       return((HWND)0);
  2523.      }
  2524.  
  2525.    /* return the handle to the frame window                                */
  2526.    return(hWndFrame);
  2527. }  /* End of cwCreateWindow */
  2528.  
  2529.  
  2530. /***************************************************************************/
  2531. /*  cwCenter Function                                                      */
  2532. /*                                                                         */
  2533. /*  Centers a dialog box on the client area of the caller                  */
  2534. /*                                                                         */
  2535. /***************************************************************************/
  2536.  
  2537. INT cwCenter(hWnd, hWndParent)                                              
  2538. HWND hWnd;         /* handle of the window to be centered                  */
  2539. HWND hWndParent;   /* handle of the window to center on                    */
  2540. {
  2541.   ULONG  SrcX, SrcY;                /* Center of parent                    */
  2542.   INT    ix, iy;                    /* Destination points                  */
  2543.   SWP    DlgSwp, ParentSwp;         /* Set window position structures      */
  2544.   ULONG  ScreenWidth, ScreenHeight; /* Dimensions of the DESKTOP           */
  2545.   POINTL pt;                        /* Point                               */
  2546.  
  2547.   /* Determine the width and height of the DESKTOP so the dialog box       */
  2548.   /* will not be positioned to a point off of the screen.                  */
  2549.   ScreenWidth  = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  2550.   ScreenHeight = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  2551.  
  2552.   /* Query width and depth of dialog box                                   */
  2553.   WinQueryWindowPos(hWnd, (PSWP)&DlgSwp);
  2554.  
  2555.   /* Query width and depth of caller                                       */
  2556.   WinQueryWindowPos(hWndParent, (PSWP)&ParentSwp);
  2557.  
  2558.   /* Map the point parent points to the Desktop                            */
  2559.   pt.x = ParentSwp.x;
  2560.   pt.y = ParentSwp.y;
  2561.  
  2562.   /* Convert the point from having our window as the origin to having      */
  2563.   /* the DESKTOP as the origin                                             */
  2564.   WinMapWindowPoints(hWndParent, HWND_DESKTOP, &pt, 1);
  2565.  
  2566.   SrcX = pt.x + (ParentSwp.cx / 2);
  2567.   SrcY = pt.y + (ParentSwp.cy / 2);
  2568.  
  2569.   /* Determine the point to move the dialog box to                         */
  2570.   ix = (INT)(SrcX - (DlgSwp.cx / 2));
  2571.   iy = (INT)(SrcY - (DlgSwp.cy / 2));
  2572.  
  2573.   /* if either point is less than zero, then set that point to zero        */
  2574.   /* so the dialog box will not be positoned off of the window             */
  2575.   ix = (ix < 0) ? 0 : ix;
  2576.   iy = (iy < 0) ? 0 : iy;
  2577.  
  2578.   /* if either point plus the height or width of the dialog box is         */
  2579.   /* greater than the height or width of the screen adjust point           */
  2580.   if(((ULONG)ix + DlgSwp.cx) > ScreenWidth)
  2581.     ix = (INT)(ScreenWidth - DlgSwp.cx);
  2582.   if(((ULONG)iy + DlgSwp.cy) > ScreenHeight)
  2583.     iy = (INT)(ScreenHeight - DlgSwp.cy);
  2584.  
  2585.   /* move the dialog box                                                   */
  2586.   return(WinSetWindowPos(hWnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE));
  2587. }
  2588.  
  2589.  
  2590. /* This function initializes the states of all dialog box radio buttons    */
  2591. /* and check boxes that have had their initial status set to true          */
  2592. INT cwSetInitDlgStatus(hWnd)
  2593. HWND hWnd;
  2594. {
  2595.   CATStruct FAR *Cat;
  2596.  
  2597.   OFFSETOF(Cat) = 0;
  2598.   DosAllocSeg(sizeof(CATStruct), (PSEL)&SELECTOROF(Cat), 0);
  2599.   lmemset(Cat, 0x00, sizeof(CATStruct));
  2600.   WinSetWindowULong(hWnd, OFFSET_CAT, (ULONG)Cat);
  2601.   Cat->YourWindowsTitleGoesHere = 257;
  2602.  
  2603. }
  2604.  
  2605. INT cwFreeDlgMemory(hWnd)
  2606. HWND hWnd;
  2607. {
  2608.   CATStruct FAR *Cat;
  2609.  
  2610.   Cat = (CATStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CAT);
  2611.   DosFreeSeg(SELECTOROF(Cat));
  2612. }
  2613.  
  2614. void lmemset(memptr, value, size)
  2615. void FAR *memptr;
  2616. char     value;
  2617. int      size;
  2618. {
  2619.    char FAR *chrptr = memptr;
  2620.  
  2621.    while (size--)
  2622.       *chrptr++ = value;
  2623. }
  2624.  
  2625. /* LONGSTRCPY - is a functional equivalent to the C library routine        */
  2626. /*              strcpy, with the exception that it takes far pointers to   */
  2627. /*              to character strings as it's parameters.                   */
  2628. PSZ longstrcpy(target, source)
  2629. PSZ target;
  2630. PSZ source;
  2631. {
  2632.  PSZ z = target;
  2633.  while(*target++ = *source++);
  2634.  return(z);
  2635. }
  2636.  
  2637.  
  2638. int cwCheckDlgItem(hWndDlg, id, state)
  2639. HWND hWndDlg;
  2640. INT  id;
  2641. INT  state;
  2642. {
  2643.  return((INT)WinSendDlgItemMsg(hWndDlg, id,
  2644.                                BM_SETCHECK, MPFROMSHORT(state), 0L));
  2645. }
  2646.  
  2647. /*............................................................
  2648. :                                                            :
  2649. :  ..........................................................:...........
  2650. :  :                                                                    :
  2651. :..:   db_crash()                                                       :
  2652.    :                                                                    :
  2653.    :...................................................................*/
  2654.  
  2655.   void db_crash(void)
  2656.      {
  2657.      int x;
  2658.  
  2659.      ltoa(sqlca.sqlcode, sz_code, 10);
  2660.  
  2661.      if (!bit_flag.time)
  2662.         {
  2663.         while(!kbhit())
  2664.            {
  2665.            DosBeep(500,500);
  2666.            DosSleep(DELAY);
  2667.            }
  2668.         }
  2669.  
  2670.      DosBeep(500,500);
  2671.      DosSleep(DELAY);
  2672.  
  2673.      } /* end db_crash */
  2674.  
  2675. /*............................................................
  2676. :                                                            :
  2677. :  ..........................................................:...........
  2678. :  :                                                                    :
  2679. :..:   sort_users()                                                     :
  2680.    :                                                                    :
  2681.    :...................................................................*/
  2682.  
  2683.   void sort_users(void)
  2684.      {
  2685.      register int a;
  2686.      register int b;
  2687.  
  2688.      for(a=1;a<basestat.connects;a++)
  2689.         {
  2690.         basestat.ustat[100] = basestat.ustat[a];
  2691.         b = a - 1;
  2692.         while((b >= 0) && (strncmp(basestat.ustat[100].authid,
  2693.               basestat.ustat[b].authid, 16)) < 0 )
  2694.            {
  2695.            basestat.ustat[b+1] = basestat.ustat[b];
  2696.            b--;
  2697.            }
  2698.  
  2699.         basestat.ustat[b+1] = basestat.ustat[100];
  2700.         }
  2701.  
  2702.      } /* end sort_users() */
  2703.  
  2704. /*............................................................
  2705. :                                                            :
  2706. :  ..........................................................:...........
  2707. :  :                                                                    :
  2708. :..:   LimitLBox(HWND, USHORT)                                          :
  2709.    :                                                                    :
  2710.    :...................................................................*/
  2711.  
  2712. static  FONTMETRICS g_font_metrics;
  2713.  
  2714. static  SHORT       sFontInitialized = 0;
  2715. static  CHAR        sz_temp_string[1024];
  2716.  
  2717. MRESULT EXPENTRY LimitLBox( HWND hWndDlg, USHORT sLength ) 
  2718. {
  2719.     HPS         hps;
  2720.  
  2721.     if ( !sFontInitialized ) 
  2722.         {
  2723.         sFontInitialized = 1;
  2724.         hps = WinBeginPaint( hWndDlg, NULL, NULL );
  2725.         GpiQueryFontMetrics( hps, (LONG)sizeof(FONTMETRICS), &g_font_metrics );
  2726.         WinEndPaint( hps );
  2727.         }
  2728.     return( MPFROM2SHORT( g_font_metrics.lMaxBaselineExt, sLength ) );
  2729. }
  2730.  
  2731. /*............................................................
  2732. :                                                            :
  2733. :  ..........................................................:...........
  2734. :  :                                                                    :
  2735. :..:   AlignLBox(HWND, USHORT, USHORT, MPARAM)                          :
  2736.    :                                                                    :
  2737.    :...................................................................*/
  2738.  
  2739. MRESULT EXPENTRY AlignLBox( HWND hWndDlg, USHORT sResource, 
  2740.                             USHORT *cols, MPARAM mparam2 )
  2741. {
  2742.     POWNERITEM     ptr_owner_item;
  2743.     RECTL          rectl;
  2744.     POINTL         ptl;
  2745.     PCHAR          psz_token;
  2746.  
  2747.     memset( sz_temp_string, '\0', sizeof(sz_temp_string) );
  2748.  
  2749.     ptr_owner_item = (POWNERITEM)PVOIDFROMMP( mparam2 );
  2750.  
  2751.     WinSendDlgItemMsg( hWndDlg, sResource, LM_QUERYITEMTEXT, 
  2752.         MPFROM2SHORT( ptr_owner_item->idItem, sizeof(sz_temp_string) ),
  2753.         MPFROMP( sz_temp_string ));
  2754.  
  2755.     rectl.xLeft     = ptr_owner_item->rclItem.xLeft;
  2756.     rectl.yBottom   = ptr_owner_item->rclItem.yBottom;
  2757.     rectl.xRight    = ptr_owner_item->rclItem.xRight;
  2758.     rectl.yTop      = ptr_owner_item->rclItem.yTop;
  2759.  
  2760.     ptl.x = rectl.xLeft;
  2761.     ptl.y = rectl.yBottom + g_font_metrics.lMaxDescender;
  2762.  
  2763.     WinFillRect( ptr_owner_item->hps, &rectl, SYSCLR_WINDOW );
  2764.  
  2765.     if ( ptr_owner_item->fsState == FALSE && ptr_owner_item->fsStateOld == TRUE )
  2766.         GpiSetBackColor( ptr_owner_item->hps, CLR_WHITE );
  2767.  
  2768.     psz_token = strtok( sz_temp_string, "~" );
  2769.     while ( psz_token != NULL )
  2770.         {
  2771.         ptl.x += *cols++;
  2772.         GpiCharStringAt( ptr_owner_item->hps, &ptl,
  2773.             (LONG)strlen( psz_token ), psz_token );
  2774.         psz_token = strtok( NULL, "~" );
  2775.         }
  2776.  
  2777.     if ( ptr_owner_item->fsState == FALSE && ptr_owner_item->fsStateOld == TRUE )
  2778.         ptr_owner_item->fsStateOld = FALSE;
  2779.  
  2780.     return (MRESULT) 1;
  2781. }
  2782.  
  2783. /*............................................................
  2784. :                                                            :
  2785. :  ..........................................................:...........
  2786. :  :                                                                    :
  2787. :..:   get_time()                                                       :
  2788.    :                                                                    :
  2789.    :...................................................................*/
  2790.  
  2791.   void get_time()
  2792.      {
  2793.      time(&bintime);
  2794.  
  2795.      curtime = localtime(&bintime);     
  2796.  
  2797.      } /* end get_time() */
  2798.  
  2799. /*.............................................................
  2800. :                                                             :
  2801. :   main                                                      :
  2802. :      .......................................................:......
  2803. :      :                                                            :
  2804. :      :   ctrl                                                     :
  2805. :......:    ........................................................:......
  2806.        :    :                                                             :
  2807.        :    :                                                             :
  2808.        :....:   write_user_stats(void)                                    :
  2809.             :                                                             :
  2810.             :                                                             :
  2811.             :............................................................*/
  2812.  
  2813.   void write_user_stats(void)
  2814.      {
  2815.      char           sz_trans[17];
  2816.      char           sz_sql_con[17];
  2817.      char           sz_sql_trans[17];
  2818.      char           sz_trans_time[17];
  2819.  
  2820.      unsigned short us_buff_size;
  2821.      unsigned short i;
  2822.      
  2823.      for(i=0;i<basestat.connects;i++)
  2824.         {
  2825.         strcpy(sz_user_buff, "User: ");
  2826.         strncat(sz_user_buff, basestat.ustat[i].authid, 8);
  2827.  
  2828.         strcat(sz_user_buff, " Node: ");
  2829.         strncat(sz_user_buff, basestat.ustat[i].node, 8);
  2830. /*
  2831.         strcat(sz_user_buff, " Auth. Level: ");
  2832.  
  2833.         if (basestat.ustat[i].authority_lvl & SQL_SYSADM)
  2834.            {
  2835.            strcat(sz_user_buff, "SYS ADM");
  2836.            }
  2837.  
  2838.         if (basestat.ustat[i].authority_lvl & SQL_DBADM)
  2839.            {
  2840.            strcat(sz_user_buff, "DB  ADM");
  2841.            }
  2842.  
  2843.         if (basestat.ustat[i].authority_lvl & SQL_CONNECT)
  2844.            {
  2845.            strcat(sz_user_buff, "CONNECT");
  2846.            }                     
  2847. */
  2848.         strcat(sz_user_buff, " Connect Time: "); 
  2849.         con_time = bintime - basestat.ustat[i].connect_time;
  2850.         out_time = localtime(&con_time);
  2851.         strncat(sz_user_buff, asctime(out_time), 24);
  2852.  
  2853.         strcat(sz_user_buff, " Trans/connect: ");
  2854.         ltoa(basestat.ustat[i].con_trans, sz_trans, 10);
  2855.         strncat(sz_user_buff, sz_trans, 16);
  2856.  
  2857.         strcat(sz_user_buff, " SQL/connect: ");
  2858.         ltoa(basestat.ustat[i].con_reqs, sz_sql_con, 10);
  2859.         strncat(sz_user_buff, sz_sql_con, 16);
  2860.  
  2861.         strcat(sz_user_buff, " SQL/trans: ");
  2862.         ltoa(basestat.ustat[i].cur_reqs, sz_sql_trans, 10);
  2863.         strncat(sz_user_buff, sz_sql_trans, 16);
  2864.  
  2865.         strcat(sz_user_buff, " Sec. curr/trans: ");
  2866.         ltoa(basestat.ustat[i].trans_time, sz_trans_time, 10);
  2867.         strncat(sz_user_buff, sz_sql_trans, 16);
  2868.  
  2869.         strcat(sz_user_buff, " T.S.: ");
  2870.         if (basestat.ustat[i].trans_state == 'S')
  2871.            {
  2872.            strcat(sz_user_buff, "S");
  2873.            }
  2874.  
  2875.         if (basestat.ustat[i].trans_state == 'R')
  2876.            {
  2877.            strcat(sz_user_buff, "R");
  2878.            }
  2879.  
  2880.         if (basestat.ustat[i].trans_state == 'C')
  2881.            {
  2882.            strcat(sz_user_buff, "C");
  2883.            }
  2884.  
  2885.         strcat(sz_user_buff, " L.S.: ");
  2886.         if (basestat.ustat[i].lock_state == 'W')
  2887.            {
  2888.            strcat(sz_user_buff, "W");
  2889.            }
  2890.         else
  2891.            {
  2892.            strcat(sz_user_buff, "N");
  2893.            }
  2894.  
  2895.         fprintf(spyfile, "%s\n", sz_user_buff);
  2896.  
  2897.         } /* end of while */
  2898.  
  2899.      fprintf(spyfile, "\n");
  2900. /*     bit_flag.exit = TRUE;    */
  2901.  
  2902.      } /* end write_user_stats() */
  2903.  
  2904. /*.............................................................
  2905. :                                                             :
  2906. :   main                                                      :
  2907. :      .......................................................:......
  2908. :      :                                                            :
  2909. :      :   ctrl                                                     :
  2910. :......:    ........................................................:......
  2911.        :    :                                                             :
  2912.        :    :                                                             :
  2913.        :....:   write_db_stats()                                          :
  2914.             :                                                             :
  2915.             :                                                             :
  2916.             :............................................................*/
  2917.  
  2918.   void write_db_stats()
  2919.      {
  2920.      strncpy(sz_buff, basestat.release_lvl, 4);
  2921.      strcat(sz_buff, " ");
  2922.      strncat(sz_buff, basestat.corr_serv_lvl, 8);
  2923.  
  2924.      fprintf(spyfile, "%s\n", sz_buff);
  2925.  
  2926.      strcpy(sz_buff, "Database Name: ");
  2927.      strncat(sz_buff, basestat.db_name, 16);
  2928.  
  2929.      fprintf(spyfile, "%s\n", sz_buff);
  2930.  
  2931.      strcpy(sz_buff, "Database alias: ");
  2932.      strncat(sz_buff, basestat.db_alias, 16);
  2933.  
  2934.      fprintf(spyfile, "%s\n", sz_buff);
  2935.  
  2936.      strcpy(sz_buff, "Drive: ");
  2937.      strncat(sz_buff, basestat.drive, 2);
  2938.  
  2939.      fprintf(spyfile, "%s\n", sz_buff);
  2940.  
  2941.      strcpy(sz_buff, "Location: ");
  2942.      if (basestat.location == 'L')
  2943.         {
  2944.         strcat(sz_buff, "Local");
  2945.         }
  2946.      else
  2947.         {
  2948.         strcat(sz_buff, "Remote");
  2949.         }
  2950.  
  2951.      fprintf(spyfile, "%s\n", sz_buff);
  2952.  
  2953.      strcpy(sz_buff, "Node: ");
  2954.      strncat(sz_buff, basestat.node, 8);
  2955.  
  2956.      fprintf(spyfile, "%s\n", sz_buff);
  2957.  
  2958.      strcpy(sz_buff, "Current connects: ");
  2959.      itoa(basestat.connects, sz_conns, 10);
  2960.      strcat(sz_buff, sz_conns);
  2961.  
  2962.      fprintf(spyfile, "%s\n", sz_buff);
  2963.  
  2964.      get_time();
  2965.  
  2966.      fprintf(spyfile, "%s\n", asctime(curtime));
  2967.      fprintf(spyfile, "\n");
  2968.  
  2969.   } /* end of write_db_stats() */
  2970.  
  2971. /*.............................................................
  2972. :                                                             :
  2973. :                                                             :
  2974. :   refresh_thread()                                          :
  2975. :                                                             :
  2976. :                                                             :
  2977. :............................................................*/
  2978.  
  2979.   void refresh_thread(void)
  2980.      {
  2981.      short i;
  2982.  
  2983.      while(!bit_flag.tend)
  2984.         {
  2985.         for(i=0;i<us_scan;i++)
  2986.            {
  2987.            DosSleep(SLEEP_TIME);
  2988.            }
  2989.  
  2990.         if (!bit_flag.draw)
  2991.            {
  2992.            WinPostMsg(hWndReFresh, WM_REDRAW, 0L, 0L);
  2993.            }
  2994.         }
  2995.  
  2996.      _endthread();
  2997.      } /* end of refresh_thread() */
  2998.  
  2999. /*.............................................................
  3000. :                                                             :
  3001. :                                                             :
  3002. :   wch_thread()                                              :
  3003. :                                                             :
  3004. :                                                             :
  3005. :............................................................*/
  3006.  
  3007.   void wch_thread(void)
  3008.      {
  3009.      static short i;
  3010.  
  3011.      for(i=0;i<(us_scan * 3);i++)
  3012.         {
  3013.         DosSleep(SLEEP_TIME);
  3014.         if (bit_flag.time)
  3015.            {
  3016.            _endthread();
  3017.            }
  3018.         }
  3019.  
  3020.      if (!bit_flag.time)
  3021.         {
  3022.         db_crash();
  3023.         }
  3024.  
  3025.      _endthread();
  3026.      } /* end of wch_thread() */
  3027.